Board index » cppbuilder » Winsock error

Winsock error


2005-11-28 10:38:30 PM
cppbuilder32
"an operation on a socket could not be performed because the system lacked
sufficient buffer space or because a queue was full (10055), on API
'connect'"
I see this error message in my application log. I can't find a solution for
this. How can I solve this problem.
Thanks for help.
 
 

Re:Winsock error

"OKusmen" < XXXX@XXXXX.COM >wrote in message
Quote
I see this error message in my application log. I can't find
a solution for this. How can I solve this problem.
Are you attempting to reconnect over and over? Calling connect()
repeatedly, such a in a loop until the connnection finally succeeds, without
fully cleaning up the socket in between, can cause that error.
Where exactly are you getting the error from? Can you show the actual code?
Gambit
 

Re:Winsock error

My application is a message server.So that, application connects to many clients.
TClientSocket is used for this operation in the server. In my client application has
a server socket. Socket no 50101. When message server wants to connect a closed client,
retry three times to connect.
void __fastcall TTCPSendDataModule::OnOperationalTimer(TObject */*Sender*/)
{
DisableTimer(OperationalTimer);
try
{
if( !ackWaiting && !connectionWaiting && !SendSocket->Active )// no connection request applied and no data feedback waiting
{
SendPacketInOrder();
}
}catch(const Exception &e){
}
EnableTimer(OperationalTimer);
}
//-----------------------------------------------
void __fastcall TTCPSendDataModule::SendPacketInOrder()
{
CloseSendSocket();
SendSocket->Port = 0;
SendSocket->Host = "";
SendSocket->Address = "";
SendSocket->Address = ip_address;
try{
SendSocket->Open();
}catch(const Exception &e){
CloseSendSocket();
}
}
//---------------------------------------------------------------------------
void TTCPSendDataModule::CloseSendSocket()
{
try{
SendSocket->Close();
SendSocket->Port = 0;
SendSocket->Active = false;
WriteToLog("TCP Gönderme Modül? Socket kapatıld?");
}catch(const Exception &e)
{
WriteToLog("TCP Send Module Error4.Hata="+e.Message);
}
}
//---------------------------------------------------------------------------
void __fastcall TTCPSendDataModule::SendSocketError(TObject */*Sender*/,
TCustomWinSocket */*Socket*/, TErrorEvent /*ErrorEvent*/, int &ErrorCode)
{
try
{
ErrorCode = 0;
CloseSendSocket();
}catch(const Exception &e){
}
}
//---------------------------------------------------------------------------
// Socket Connect event
//---------------------------------------------------------------------------
void __fastcall TTCPSendDataModule::SendSocketConnect(TObject */*Sender*/,
TCustomWinSocket */*Socket*/)
{
try
{
SendFirstPacket();
}catch(const Exception &e){
}
}
After sending packet, I wait hig-level ack packet from client application. After receiving ack packet,
closesendsocket function is called.And then, another client transmission is started
 

{smallsort}

Re:Winsock error

"Okusmen" < XXXX@XXXXX.COM >wrote in message
Quote
try{
SendSocket->Open();
}catch(const Exception &e){
CloseSendSocket();
}
That won't always work. When Open() throws an exception, it can leave the
socket in an indeterminate state that Close() does not fully recover from.
You would be better off just freeing the TClientSocket object and then
reinstantiate it. That ensures that all resources are fully released.
Quote
SendSocket->Close();
SendSocket->Port = 0;
SendSocket->Active = false;
Why are you closing the socket twice?
Quote
void __fastcall TTCPSendDataModule::SendSocketError(TObject */*Sender*/,
TCustomWinSocket */*Socket*/, TErrorEvent /*ErrorEvent*/, int
&ErrorCode)
{
try
{
ErrorCode = 0;
CloseSendSocket();
}catch(const Exception &e){
}
}
You should be caling Close() on the Socket parameter, not the TClientSocket
object directly.
Gambit