By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,254 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

Asynchronous Socket Client always connected

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.