🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #3067

Re: Winsock error

#3067
From: Okusmen
Date: Thu, 01 Dec 2005 09:06
80 lines
3266 bytes
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
Technical Details
Message-ID: <438ecb2f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <438b17b9@newsgroups.borland.com> <438be864$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,f5adeb6c598c786f
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII
From: "Okusmen" <okusmen@aselsan.com.tr>
Sender: "Okusmen" <okusmen@aselsan.com.tr>
Reply-To: "Okusmen" <okusmen@aselsan.com.tr>
Subject: Re: Winsock error
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 81.215.231.145     
References: <438b17b9@newsgroups.borland.com> <438be864$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <438ecb2f$1@newsgroups.borland.com>
Date: 1 Dec 2005 02:06:39 -0700
X-Trace: newsgroups.borland.com 1133431599 207.105.83.66 (1 Dec 2005 02:06:39 -0700)
Lines: 80
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail