socket exceptions

D

Droopy

Hi,

I wrote a program that runs on about 20 machines.
Each machine is connected with a socket on all other machines.
Each socket has its own handling thread.
The main reading loop is using Poll () with a 100ms timeout and Receive ()
to check incoming data.
Send () is used to send data.
There are exchanging many small messages (most are less than 250 bytes).
It runs well for a few hours than I got socket exceptions, mainly "An
existing connection was forcibly closed by the remote host" when reading or
sending and "A connection attempt failed because the connected party did
not properly respond after a period of time, or established connection
failed because connected host has failed to respond" when sending.

So, I am looking for a clue !
Is my program wrong or is there any network trouble ?

I am using C# and framework 1.1

Thanks in advance.

Droopy.
 
V

Vadym Stetsyak

Do you have any reconnect mechanism?

You mean that each machine has 20 connections on all other?
if the number of machines will grow you'll receive scalability issues
( http://msdn.microsoft.com/msdnmag/issues/05/08/HighPerformanceSockets/ )

What will happen if polling socket for 100 ms will not be successful ( no
data yet received ).

Maybe your issue is that conneciton is closed because of timeout. You can
increase this timeout by seting
socket options. However, I'd recommend you redesign your application.
 
D

Droopy

Do you have any reconnect mechanism?

That's what I am doing right now but as delivering is quite near, I would
prefer if this was not needed ;-)
You mean that each machine has 20 connections on all other?

Yes.
I have to exchange data between any machine.
Except if I use UDP (multicasting for example), how can I do it in a
better way ?
if the number of machines will grow you'll receive scalability issues
( http://msdn.microsoft.com/msdnmag/issues/05/08/HighPerformanceSockets
/ )

I know this article and I know performance (and especially scalibility)
could be better but that is not the problem for now.
We should use about 70 machines in the comming weeks.
What will happen if polling socket for 100 ms will not be successful
( no data yet received ).

It is a loop in a dedicated thread so no problem here.
Maybe your issue is that conneciton is closed because of timeout. You
can increase this timeout by seting
socket options. However, I'd recommend you redesign your application.

I also thought about a timeout problem but what timeout are you talking
about ?
A redesign is planned but for the 1st release, it is impossible.

Thanks for your help.
 
V

Vadym Stetsyak

I also thought about a timeout problem but what timeout are you talking


TCP connection has a timeout. And if no data is being passed through network
remote host may close connection.
This can be solved in 2 ways using socket options:
- set connection timeout ( SocketOptionName.ReceiveTimeout )
- set keepalive option ( SocketOptionName.KeepAlive )
I have to exchange data between any machine.
Except if I use UDP (multicasting for example), how can I do it in a
better way ?

Is data specific for particular machine?
I mean that if it is not you can brake the logic into server app and client
app.
Server will receive connections.
When client sends data - server resends it to other connections. ( like
start topology )

IMO if these 70 machines will be in the intranet multicast approach will be
okay
 
D

Droopy

TCP connection has a timeout. And if no data is being passed through
network remote host may close connection.
This can be solved in 2 ways using socket options:
- set connection timeout ( SocketOptionName.ReceiveTimeout )
- set keepalive option ( SocketOptionName.KeepAlive )


Is data specific for particular machine?
I mean that if it is not you can brake the logic into server app and
client app.
Server will receive connections.
When client sends data - server resends it to other connections. (
like start topology )

Not a bad idea.
IMO if these 70 machines will be in the intranet multicast approach
will be okay

If I am asked to implement a redesign, I will think about your
suggestion.
Anyway, thanks a lot for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top