473,386 Members | 1,827 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,386 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 4815
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: 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
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...
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
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,...

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.