473,624 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Sock ets.SocketExcep tion: 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.closesoc ket 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 4861
Bah sorry, wrong forum, well unless someone knows. :)

"J. Dudgeon" <j-*************** ***@ca.unisys.c om> wrote in message
news:O6******** ******@TK2MSFTN GP10.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.Sock ets.SocketExcep tion: 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.closesoc ket 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
434
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 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.
3
2536
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 and recieving data and call the Close() method the socket lingers for a couple of minutes. This is demonstrated by using netstat -a. I've tried an assortment of SocketOptions (Linger, and DontLinger), but
13
2640
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 problem is executing the transactions against the remote server and returning the response to the remoting client. i can open the socket fine and, if i am executing one transaction at a time, everything works great. it's when my proxy server...
9
8700
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 increase the limit. How do you do that in C# in the .NET Visual Studio environment? I could potentially have 1000's of simultaneous connections, so running each socket in it's own thread doesn't seem very practical. Stuart.
6
3542
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 every message? Also, the message is complete, meaning there is no more data to read, only when the client closes the connection. My solution is to keep the connection open, and send a terminator / eof at the end of every message. Is it the right...
2
6869
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 there is a problem with the connection. I need to know which client has sent the incoming data as each client has its own buffer on my "server" app. I am using the standard asynch socket code from MSDN to listen for connections and they...
0
4670
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 number of different types of data coming in. I have a databuffer for each type of data coming in.
11
8592
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 mechanisms. I use a non-blocking approach for this, using the call to 'poll' to support the async mechanism - rather than the 'begin' and 'end' functions. I already found that connecting doesn't set the "isconnected" variable correctly...
3
3043
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); m_networkSocket.Blocking = true; m_networkSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true); m_networkSocket.SetSocketOption(SocketOptionLevel.Socket,
0
8249
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
8179
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
8685
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...
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8493
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...
0
7176
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
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.