471,334 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

socket exceptions

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.
Jan 11 '06 #1
4 1659
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/is...rmanceSockets/ )

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.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.71...
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.

Jan 11 '06 #2
"Vadym Stetsyak" <va*****@ukr.net> wrote in
news:#G**************@TK2MSFTNGP10.phx.gbl:
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/is...ormanceSockets
/ )

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.

Jan 11 '06 #3
> I also thought about a timeout problem but what timeout are you talking
about ?

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

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com
Jan 11 '06 #4
"Vadym Stetsyak" <va*****@ukr.net> wrote in
news:ew*************@TK2MSFTNGP15.phx.gbl:
I also thought about a timeout problem but what timeout are you
talking about ?

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 )


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.

Jan 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by faktujaa | last post: by
1 post views Thread by Mr. Beck | last post: by
14 posts views Thread by =?Utf-8?B?TWlrZVo=?= | last post: by
10 posts views Thread by ThunderMusic | last post: by
4 posts views Thread by Adam Clauss | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.