Asynchronous Socket Client always connected

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

Hi

I write dll library which one of it component will be Net socket
communication. Communication is working very good, but i've got problem when
client is connecting. When server is started, client is connecting without
problems; but when servre is down and i start client, client connect to
server!
Few lines from code:

client.Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
client.Socket.BeginConnect(client.EndPoint, new
AsyncCallback(Client_ConnectCallback), client);

and in callback

client.Socket.EndConnect(ar);

Of course client.Socket.Connected is after callback set to true.

What is strange when i call :

client.Socket.BeginSend(msg.Data, 0, msg.Data.Length, SocketFlags.None, new
AsyncCallback(Client_SendCallback), client);
there is no problems.

Receive of course doesn't work.

I execute netstat.exe and connection is alive. So where is this client
connected?

Maybe somebody knew how to test this connection, or how to check this
connection is alive and working?

Of course i can check, that some data was received - but i cannot asure that
some data will be received in some time period.

regards

Kuba Florczyk
 
Back
Top