473,396 Members | 1,826 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,396 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 1730
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.