Does anyone know why the BeginAccept doesn't work? If, in the code
below, I do the normal Accept function I can get the client socket but
it seems that the callback isn't really called.
Here's the code:
-----------------------------
private Socket socket;
private Socket clientSocket;
public TcpServer(strin g serverIP,int serverPort)
{
clientSocket=nu ll;
socket=new
Socket(AddressF amily.InterNetw ork,SocketType. Stream,Protocol Type.Tcp);
IPEndPoint ep=new IPEndPoint(IPAd dress.Parse(ser verIP),serverPo rt);
socket.Bind(ep) ;
socket.Listen(1 0);
socket.BeginAcc ept(new AsyncCallback(A cceptConnection ),socket);
}
private void AcceptConnectio n(IAsyncResult ar)
{
Socket socket=(Socket) ar.AsyncState;
clientSocket=so cket.EndAccept( ar);
//throw new Exception("TCP Accepted on
#"+clientSocket .RemoteEndPoint .ToString());
throw new Exception("Yuhu u");
}