473,326 Members | 2,010 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,326 software developers and data experts.

Socket handles/connections lingering?

Hello,

I've written a server that acts as a proxy between the PC and the mainframe
worlds. This server service is writting in C# w/.NET 1.1. The service is
TCP/IP based and makes heavy use of sockets.

The "client" to the service is a C# class library that also uses sockets.
I've managed to get the performance of the service up to a decent speed but
I've hit a strange problem.

My test program (that uses the C# class library) runs a series of
transactions on multiple threads for a configurable number of iterations.
Everything runs fine up until around 3600-3900 transactions (total) at which
point my C# class library throws a SocketException from the Socket.Connect
call:

System.Net.Sockets.SocketException: Only one usage of each socket address
(protocol/network address/port) is normally permitted.

I understand what this message is saying but I don't know why I'm getting
it. The C# class library guarantees, in its Dispose() method that
Socket.Close() is called (to free the underlying socket handle.) The test
program wraps the C# class in a "using" block to ensure the Dispose() method
is called on my C# class (which inherits from IDisposable.) I even tried
setting the DontLinger option to true but the problem remains. Doing a
"NETSTAT -a" in the console shows numerous TCP/IP connections from the test
program to the service with a TIME_WAIT status; so, apparently all the
sockets are being consumed and not released fast enough.

If I terminate the process (or even wait a while) I can run another 3600
transactions before getting this error. The problem with this is that I can
reach 3600 transactions in about 1 minute.

Is what I'm seeing a bug in System.dll library? Peeking into the source
shows that the Socket class calls OSSOCK.closesocket in its Dispose()
method, so I'm not sure why things aren't getting closed. Eventually the
socket handles are freed but it seems to take just long enough to cause
issues.

Is there a socket option that I can set to alleviate this issue? Can
Windows just not keep up with freeing the socket handles?

Any help would be greatly appreciated.

Thank you in advance,

Joel
Nov 16 '05 #1
1 4808
Bah sorry, wrong forum, well unless someone knows. :)

"J. Dudgeon" <j-******************@ca.unisys.com> wrote in message
news:O6**************@TK2MSFTNGP10.phx.gbl...
Hello,

I've written a server that acts as a proxy between the PC and the mainframe worlds. This server service is writting in C# w/.NET 1.1. The service is
TCP/IP based and makes heavy use of sockets.

The "client" to the service is a C# class library that also uses sockets.
I've managed to get the performance of the service up to a decent speed but I've hit a strange problem.

My test program (that uses the C# class library) runs a series of
transactions on multiple threads for a configurable number of iterations.
Everything runs fine up until around 3600-3900 transactions (total) at which point my C# class library throws a SocketException from the Socket.Connect
call:

System.Net.Sockets.SocketException: Only one usage of each socket address
(protocol/network address/port) is normally permitted.

I understand what this message is saying but I don't know why I'm getting
it. The C# class library guarantees, in its Dispose() method that
Socket.Close() is called (to free the underlying socket handle.) The test
program wraps the C# class in a "using" block to ensure the Dispose() method is called on my C# class (which inherits from IDisposable.) I even tried
setting the DontLinger option to true but the problem remains. Doing a
"NETSTAT -a" in the console shows numerous TCP/IP connections from the test program to the service with a TIME_WAIT status; so, apparently all the
sockets are being consumed and not released fast enough.

If I terminate the process (or even wait a while) I can run another 3600
transactions before getting this error. The problem with this is that I can reach 3600 transactions in about 1 minute.

Is what I'm seeing a bug in System.dll library? Peeking into the source
shows that the Socket class calls OSSOCK.closesocket in its Dispose()
method, so I'm not sure why things aren't getting closed. Eventually the
socket handles are freed but it seems to take just long enough to cause
issues.

Is there a socket option that I can set to alleviate this issue? Can
Windows just not keep up with freeing the socket handles?

Any help would be greatly appreciated.

Thank you in advance,

Joel

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: J. Dudgeon | last post by:
Hello, I've written a server that acts as a proxy between the PC and the mainframe worlds. This server service is writting in C# w/.NET 1.1. The service is TCP/IP based and makes heavy use of...
3
by: Jimbo | last post by:
Hi Guys, I'm sorry if you have heard this one before but searching the net hasn't found a solution. I am using Socket in a client to connect to a server. However, after I've finished sending...
13
by: coloradowebdev | last post by:
i am working on basically a proxy server that handles requests via remoting from clients and executes transactions against a third-party server via TCP. the remoting site works like a champ. my...
9
by: Stuart | last post by:
I am trying to execute a Socket.Select() statement on an arraylist of sockets. The problem is that I can only go up to 64 sockets at a time. I know that I have to manipulate the FD_SetSize to...
6
by: Sharon | last post by:
Hi all. I'm trying first time async socket connection. In all the examples i've seen, the server connection is closed when the message is complete. Is it common to close the connection after...
2
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless...
0
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
3
by: A. W. Dunstan | last post by:
I'm creating a socket as follows: m_networkSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_networkSocket.LingerState = new LingerOption(true, 1);...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.