Connect still works when nothing to connect to
-
I'm writing a client for a PocketPC 2003 application, connecting to a main application server. If the client is unable to connect to the server, my application should revert to a local data source.
connectionSocket = new SocketPacket( ); IPEndPoint remoteEndPoint = new IPEndPoint( IPAddress.Parse( remoteHostIp ), remotePort ); connectionSocket.LocalSocket.Connect( remoteEndPoint ); connectionSocket.LocalSocket.BeginReceive( connectionSocket.DataBuffer, 0, SocketPacket.BufferSize, SocketFlags.None, messageReceivedCallback,connectionSocket ); Reset( );
Reset simply sends a message to the remote machine to reset comms. The problem is, the software thinks the LocalSocket.Connected = true even though it can't be so proceeds as normal. I've put a try.. catch block around this code, but it doesn't fail here it fails further down, trying to send. The Connected property I assume cannot be trusted. Does anyone have a suggested solution for this other than putting in masses of try..catch?