Solved

win32 socket error-10055(WSAENOBUFS)!!!

Posted on 2001-07-17
19
3,460 Views
Last Modified: 2012-05-04
When I run my stress test client program overnight, eventually I got this error (10055) when my client program try to reconnect/send data to the server. From the msdn, it says it is "No buffer space available". what caused this and how to prevent this ?
0
Comment
Question by:eugeneng
  • 10
  • 7
  • 2
19 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 6292753
sounds like you are not freeing resources your client uses, are you closing sockets, freeing memory etc etc.

Paul
0
 

Author Comment

by:eugeneng
ID: 6293108
it is tcp/ip connection, so I don't close socket untill the program exit, or when I need to recreate a new one. Do you mean the machine has run out of memory ?
When this error happen, I have to reboot the computer in order to run the client program again.
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293135
it sounds like you are not closing the connections, if your program creates sockets that connects to servers/hosts then you should close the socket after you have finshed then recreate a new one for further connections

pseudo code

loop
  socket = create socket
  connect address
  use socket
  closesocket socket
end loop

if you really must post the code, if its tons then mail it to me paul_maker@hotmail.com, only bother if its VC++ cos thats all i have at the moment, also do not mail me the debug directory
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:eugeneng
ID: 6293169
it is tcp/ip connection, so I don't close socket untill the program exit, or when I need to recreate a new one. Do you mean the machine has run out of memory ?
When this error happen, I have to reboot the computer in order to run the client program again.
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293176
double post
0
 

Author Comment

by:eugeneng
ID: 6293189
it is tcp/ip connection, so I don't close socket untill the program exit, or when I need to recreate a new one. Do you mean the machine has run out of memory ?
When this error happen, I have to reboot the computer in order to run the client program again.
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293194
whats up, stop posting the same comment
0
 

Author Comment

by:eugeneng
ID: 6293195
I didn't do anything, why would this happened ?
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293204
errr, EE mess up, it would not be the first time,

anyway back to the problem in hand,

wnat compiler and OS
0
 

Author Comment

by:eugeneng
ID: 6293227
this is the code I suppose to post,

bool mySocket::Connect()
{
    if (!m_Opened)
     CreateSocket();
      :
      :
     
     if (connect(m_Handle, (sockaddr *) &Address, sizeof(Address)) == SOCKET_ERROR)
     {
           m_SocketError = WSAGetLastError();
            return false;
     }

bool mySocket::CreateSocket()
{
    Close();
    m_hHandle = socket(PF_INET, SOCK_STREAM, 0);
    if (m_hHandle < 0)
    {
     m_SocketError = WSAGetLastError();
        return false;
    }
    m_Open = true;
    return true;
}

void mySocket::Close(void)
{
  if (m_Open)
 {
   shutdown(m_Handle, 2);
   closesocket(m_Handle);
 }
  m_Open = false;
}


this is my to show how do I create, connect, and close the socket, see I close the existing socket whenever I recreate a new one...

0
 

Author Comment

by:eugeneng
ID: 6293232
I'm using VC++ 6.0 on Win2k
0
 
LVL 10

Expert Comment

by:makerp
ID: 6293278
this will fix it, you should always close it before reconnecting or the old connection will not close but just hang around unreferenced

if(m_Opened)
{
 Close();
}
CreateSocket();
0
 

Author Comment

by:eugeneng
ID: 6293295
I'm using VC++ 6.0 on Win2k
0
 

Author Comment

by:eugeneng
ID: 6293319
I'm using VC++ 6.0 on Win2k
0
 

Author Comment

by:eugeneng
ID: 6293322
I'm using VC++ 6.0 on Win2k
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6294711
from http://www.jsiinc.com/SUBB/tip0900/rh0914.htm
....

An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.

Not much better.

If you are trying to use an ephemeral (short-lived) TCP port above 5000, this may explain the message. By default, Windows NT 4.0 only supports 5000 ephemeral TCP ports.

You can increase this by navigating to

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

Add Value name MaxUserPort, a type REG_DWORD, and set it to some decimal number in the range of 5000 - 65534.

Once a port is closed, it takes 4 minutes (240 seconds) before the system will reuse it. You can alter this behavior if you

Add Value name TcpTimedWaitDelay as a type REG_DWORD and set it to some decimal number in the range of 30 - 300 seconds.
....
~ same ideas see in
http://www.proxyplus.cz/faq/articles/EN/art10002.htm

may be it helps...
0
 
LVL 10

Expert Comment

by:makerp
ID: 6294735
alex, could you post me that COM example

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=cplusprog&qid=20150920

cheers

i will put the pts up to 100
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 50 total points
ID: 6304565
eugeneng , did you solved your problem with help
of my comment?
0
 

Author Comment

by:eugeneng
ID: 6306891
sorry, AlexVirochovsky, I was busy with other thing else, I don't know whether your comment will solve my problem but at least you gave me some clue on the problem. thank you any way..
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question