473,909 Members | 6,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1755
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.ne t> wrote in
news:#G******** ******@TK2MSFTN GP10.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 ( SocketOptionNam e.ReceiveTimeou t )
- set keepalive option ( SocketOptionNam e.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.ne t> wrote in
news:ew******** *****@TK2MSFTNG P15.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 ( SocketOptionNam e.ReceiveTimeou t )
- set keepalive option ( SocketOptionNam e.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
2284
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 point. System.Net.IPAddress IPAddress = System.Net.IPAddress.Parse(strPrtrIPAddr); System.Net.IPEndPoint IPEndPoint = new System.Net.IPEndPoint(IPAddress,
1
17558
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 another program for information passing. Upon receiving a particular "command" from the the information passing program, myProblemProgram will launch a separate thread to do individual communication with another file transfer program. The thread...
14
5955
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 connected. Any idea? Thanks.
2
4057
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, this deserves a documentation mention. The "socket" module, given a Unicode string, calls the International Domain Name parser, "idna.py", which has a a whole error system of its own. The IDNA documentation says that "Furthermore, the socket...
10
3601
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. File "D:\Python24\lib\socket.py", line 295, in read data = self._sock.recv(recv_size) timeout: timed out
6
7017
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 supernode. Everything I have written works fine sending and receiving uncompressed data. But now I want to implement compression using the deflate algorithm as the Gnutella protocol accepts: Accept-Encoding: deflate Content-Encoding: deflate in the...
10
5194
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 always raise a OnConnect event (actually, it calls the callback function as if there was a new connection attempt) and I receive a ObjectDisposedException as soon as I do m_mySocket.EndAccept. Does anyone have any idea of what I could do about...
6
6597
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 good API requires a lot experience and effort by illustrating the example of something as common place as the select() function call available in sockets. The example focuses on the design decision surrounding the Select() call in C#. It comes...
4
4322
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 the crash each time. We finally think we have narrowed down the cause of this to a user (located semi-remotely) who would connect into our system and disconnect "ungracefully" (literally, by pulling his network cable). Connections here are all...
0
10035
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9877
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11046
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10538
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8097
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4774
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3357
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.