467,118 Members | 1,043 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,118 developers. It's quick & easy.

Asynchronous Socket Client always connected

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
Jul 21 '05 #1
  • viewed: 2174
Share:
2 Replies
remove it :

client.Socket.EndConnect(ar);
news.microsoft.com wrote:
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


Jul 21 '05 #2
Why? What that will change?

kuba
remove it :

client.Socket.EndConnect(ar);
news.microsoft.com wrote:
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 whenclient is connecting. When server is started, client is connecting withoutproblems; 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, newAsyncCallback(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 thatsome data will be received in some time period.

regards

Kuba Florczyk

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Darren Thomas | last post: by
2 posts views Thread by news.microsoft.com | last post: by
4 posts views Thread by Matthew Groch | last post: by
reply views Thread by Richard | last post: by
7 posts views Thread by Colin | last post: by
4 posts views Thread by Engineerik | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.