I wrote a small test prog this morning just for fun. It is a very primitive and small webserver it only sends a greeting back to the webbrowser. Try it out locally on your machine with a webbrowser, then try it out with between two machines. Try changing the port from 80 to something else (I marked the line in red bold in the code) and try calling it again if it doesn't work I agree with you it might be a firewall problem. I've only got one PC at home so I cannot test it between two PCs. God Luck
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace TestSocket
{
class MiniWebServer
{
public static void OnAcceptConnection(IAsyncResult ar)
{
Socket serverSock = (Socket)ar.AsyncState;
Socket clientSocket = serverSock.EndAccept(ar);
try
{
serverSock.BeginAccept(new AsyncCallback(MiniWebServer.OnAcceptConnection),serverSock);
ClientStateObject cso = new ClientStateObject();
cso.worksocket = clientSocket;
clientSocket.BeginReceive(cso.buffer, 0, 256, SocketFlags.None,
new AsyncCallback(MiniWebServer.OnDataReceived), cso);
}
catch(Exception e)
{
serverSock.Close();
Console.WriteLine(e.ToString());
}
}
public static void OnDataReceived(IAsyncResult ar)
{
ClientStateObject cso = (ClientStateObject)ar.AsyncState;
try
{
int read = cso.worksocket.EndReceive(ar);
Console.WriteLine(Encoding.ASCII.GetString(cso.buffer,0,read).ToString());
if(read == 256)
{
cso.worksocket.BeginReceive(cso.buffer,0,256,SocketFlags.None,
new AsyncCallback(MiniWebServer.OnDataReceived), cso);
}
else
{
cso.buffer = Encoding.ASCII.GetBytes("Hello from the MiniWebServer");
cso.worksocket.BeginSend(cso.buffer, 0, cso.buffer.Length, SocketFlags.None,
new AsyncCallback(OnDataSent), cso);
}
}
catch(Exception e)
{
cso.worksocket.Close();
Console.WriteLine(e.ToString());
}
}
public static void OnDataSent(IAsyncResult