SocketException WSAENOBUFS on Socket.Connect

J

Jeronimo Bertran

I have a client application that connects to a TCP server and uses the
Socket class. The application connects every 10 minutes to the server and
exchanges information. The application runs fine but we have been having a
problem after running it for several days where we receive a socket
exception when trying to connect to the server using Socket.Connect. The
exception information is the following:

WSAENOBUFS
(10055)
No buffer space available.
An operation on a socket could not be performed because the system lacked
sufficient buffer space or because a queue was full.

I suspect that the application may not be freeing some resource under some
conditions but haven't been able to find the problem.

Is there any way to monitor these resources or resolve the problem?

Thanks

Jeronimo
 
P

Peter Huang [MSFT]

Hi Jeronimo,

Currently it is hard to narrow the problem based on my information.
As you said, this may be caused by the socket related resource is not
released.

Based on my rearch, I found many hits about this issue, but I post some for
your reference.
198663 BUG: Closesocket() on a Duplicated Socket Fails to Clean Up
http://support.microsoft.com/default.aspx?scid=kb;EN-US;198663

201213 BUG: Send() Fails with Error WSAENOBUFS Over Blocking Socket
http://support.microsoft.com/default.aspx?scid=kb;EN-US;201213

196271 When you try to connect from TCP ports greater than 5000 you receive
the error 'WSAENOBUFS (10055)'
http://support.microsoft.com/default.aspx?scid=kb;EN-US;196271

905628 You receive an error message when you run a custom Winsock network
program on a Microsoft Windows XP Service Pack 2-based computer
http://support.microsoft.com/default.aspx?scid=kb;EN-US;905628

Also I think you may try to use the TCPView tool to monitor how many TCP
connection opened from certain process(here means the client which throw
the error.
TCPView for Windows v2.4
http://www.microsoft.com/technet/sysinternals/Networking/TcpView.mspx

Also please check your code to see every 10 min, you new a socket and
connect to the remote server, afterwards, have you close the socket?
Also you may try to use the GC.AddMemoryPressure Method to suggest GC do a
garbage collect.
http://msdn2.microsoft.com/en-us/system.gc.addmemorypressure.aspx


Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
E

EmeraldShield

The first thing I would do it build a test app that connects and disconnects
constantly. Not even 10 minutes. Then you can see how quickly the system
fails. If it is always after xx number of connections then you know it is
in your cleanup code. If it still takes days then it might be somewhere
else.
WSAENOBUFS
(10055)
No buffer space available.
An operation on a socket could not be performed because the system lacked
sufficient buffer space or because a queue was full.

The only times I have seen this is when my apps were using a buffer for the
receive and never null'ing it.
Or they were never closing the socket correctly and getting the data off the
stack. So the network stack holds all this data waiting for you to pick it
up and eventually runs out of buffer space.
 
P

Peter Huang [MSFT]

Hi Jeronimo,

I am just checking to see how this is going.
Please drop me a quick note at your convenience to let me know the current
status of this issue.
If you have any concerns, please do not hesitate to let me know.
Thanks, and have a great day! :)


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top