views:

12

answers:

0

I have written a C# server application which uses Deusty.net AsyncSockets (great project by the way!) and I'm running into a very strange problem.

All the events are being processed correctly including DidRead, giving me a valid sender (IP address etc) but when it comes to disconnections, I get a strange situation where the socket data is null. Here's my (simple) code:

void _listenDataSocket_DidAccept(AsyncSocket sender, AsyncSocket socket) { log.Info(string.Format("Accepted client {0}:{1}", socket.RemoteAddress, socket.RemotePort)); socket.WillClose += new AsyncSocket.SocketWillClose(socket_WillClose); ...

Then when I close the client connection, the WillClose event is fired:

void socket_WillClose(AsyncSocket sender, Exception e) { log.Warn(string.Format("Client Disconnecting: {0}:{1}", sender.RemoteAddress, sender.RemotePort)); ...

but I get this:

WARN 2010-05-11 12:29:48,925 31812ms socket_WillClose - Client Disconnecting: :0

Notice that the remoteaddress and remoteport are blank? That's because the "sender" is null!

Does anyone know why would this be?

Thanks!