?
Solved

win32 socket error-10055(WSAENOBUFS)!!!

Posted on 2001-07-17
19
Medium Priority
?
3,543 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

840 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