473,372 Members | 837 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 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 1727
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: faktujaa | last post by:
Hi, I am having some problem with callback used in socket implementation. private static void Connect(string strPrtrIPAddr, int intPrtrPort, ref Socket rsocClient) { try { // Create remote end...
1
by: Mr. Beck | last post by:
Hello, Please Help..... I have been working with some tcp/ip socket communication within a C# program recently. Basicly, I have a program (myProblemProgram) that has a socket connected to...
14
by: =?Utf-8?B?TWlrZVo=?= | last post by:
I have a sync socket application. The client is blocked with Socket.Receive(...) in a thread, another thread calls Socket.Close(). This unblock the blocked thread. But the socket server is still...
2
by: John Nagle | last post by:
Here's a strange little bug. "socket.getaddrinfo" blows up if given a bad domain name containing ".." in Unicode. The same string in ASCII produces the correct "gaierror" exception. Actually,...
10
by: John Nagle | last post by:
Here are three network-related exceptions. These were caught by "except" with no exception type, because none of the more specific exceptions matched. This is what a traceback produced: 1....
6
by: Pat B | last post by:
Hi, I'm writing my own implementation of the Gnutella P2P protocol using C#. I have implemented it using BeginReceive and EndReceive calls so as not to block when waiting for data from the...
10
by: ThunderMusic | last post by:
Hi, I'm currently working with sockets. I accept connections using m_mySocket.Listen(BackLogCount); But when I want to stop listening, I shutdown all my clients and call m_mySocket.Close(), but it...
6
by: Dilip | last post by:
I don't know how I missed this piece for so long (this may also be old news to you guys) but in this ACMQueue article, Michi Henning goes to elaborate lengths to detail how even today designing a...
4
by: Adam Clauss | last post by:
A while back I posted regarding a problem we were having with one of our applications which was randomly crashing. Monitoring memory usage revealed a spike in nonpaged pool memory just prior to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.