🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Client Socket Connect Question

#5556
From: OKusmen
Date: Thu, 05 Aug 2004 07:17
88 lines
3646 bytes
I  take host and port values from db-table. Firstly, Read them from table
and set them into socket's parameters. Actual values:
Host = "bosterminal"
Port = 50102
"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message
news:41111ce5$1@newsgroups.borland.com...
>
> "OKusmen" <okusmen@aselsan.com.tr> wrote in message
> news:41109cf1@newsgroups.borland.com...
>
> > void TTCPSendDataModule::OpenConnection()
> > {
> >         SendSocket->Host = TCPSendTable->FieldValues["HostName"];
> >         SendSocket->Port = TCPSendTable->FieldValues["PortNo"];
>
> Where exactly are you getting the Host and Port values from?  What are the
> actual values themselves?
>
> >         try{
> >          SendSocket->Open();
> >   connectionWaiting = true;
> >         }catch(...){}
>
> You should always catch VCL exceptions explitically, don't use '...':
>
>     catch(const Exception &){}
>
> >       if( SendSocket->Active &&
> > SendSocket->Socket->SendBuf(buffer,bufferLength) == bufferLength ) //
> packet
> > is sent sucessfully
> >          result = true;
> >    }catch(...){}
>
> FYI, just because SendBuf() may not take the full data at one time is not
an
> error.  Only when it returns -1 or throws an exception is it an error.
You
> should be looping through the data until you have sent it all, ie:
>
>     bool TTCPSendDataModule::SendPacket(BYTE *buffer,int bufferLength)
>     {
>         if( SendSocket->Active )
>         {
>             try
>             {
>                 while( bufferlength > 0 )
>                 {
>                     int sent = SendSocket->Socket->SendBuf(buffer,
> bufferLength);
>                     if( sent < 0 )
>                     {
>                         if( SendSocket->Active )
>                         {
>                             // send would block, try again...
>                             Application->ProcessMessages();
>                             continue;
>                         }
>
>                         // error sending and OnError already caught it...
>                         return false;
>                     }
>
>                     if( sent == 0 )
>                     {
>                         // disconnected...
>                         return false;
>                     }
>
>                     buffer += sent;
>                     bufferlength -= sent;
>                 }
>
>                 // finished...
>                 return true;
>             }
>             catch(const Exception &)
>             {
>                 // error...
>             }
>         }
>         return false;
>     }
>
>
> Gambit
>
>
Technical Details
Message-ID: <4111df6e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <410f4afe@newsgroups.borland.com> <410fbe48$1@newsgroups.borland.com> <41109cf1@newsgroups.borland.com> <41111ce5$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5e7c9fcee6f0909e
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "OKusmen" <okusmen@aselsan.com.tr>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <410f4afe@newsgroups.borland.com> <410fbe48$1@newsgroups.borland.com> <41109cf1@newsgroups.borland.com> <41111ce5$1@newsgroups.borland.com>
Subject: Re: Client Socket Connect Question
Date: Thu, 5 Aug 2004 10:17:55 +0300
Lines: 90
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 212.50.56.195
Message-ID: <4111df6e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1091690350 212.50.56.195 (5 Aug 2004 00:19:10 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail