🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: TServerSocket SendText Exception

#2473
From: Remy Lebeau (TeamB)
Date: Mon, 17 Apr 2006 21:10
56 lines
3188 bytes
"Eric Patterson" <eric.patterson@bepco.com> wrote in message
news:4443d955$1@newsgroups.borland.com...

> I understand what you mean but can't find an example on the newsgroup to
help.

Did you do a search for SendText?  Did you search for SendBuf()?  I know
that code examples exist in the archives on this topic.

SendText() calls SendBuf() internally.  Since SendText() does not allow you
specify an index into the string, it is generally more efficient to call
SendBuf() directly and not use SendText() at all.

> So I should continue to call SentText until it returns a value of ???.

That is not the way to handle it.  If you want to send 50 characters, and
SendText() only accepts 10, you have to remove the first 10 from the string
and then call SendText() again pass in only the remaining 40 characters,
repeating as needed until all 50 characters have been sent.

> I would think zero

No.  A return value of zero means that the socket was disconnected by the
other party.

> but it does state that the return value can be less then zero also.

That means that a socket error occured.  You have to use WSAGetLastError()
to find out which error occured.  The only error you can safely ignore is
WSAEWOULDBLOCK.

> What values less then zero can be returned

-1 is the only one.  It is the same value as SOCKET_ERROR, as SendText()
(and SendBuf()) simply returns whatever value the socket API send() function
returns.

> Should an OnError event be written since I will continue to SendText until
it goes through?

If an error other than WSAEWOULDBLOCK occurs, SendText() will throw an
exception, unless the OnError event handler prevents it.

> Since I am writing the same message to multiple connected clients can
> I use the OnClientWrite event somehow?

The only time the OnWrite event is triggered is when a socket becomes
writable after a blocking send occured on a non-blocking socket.  When
send() returns SOCKET_ERROR and WSAGetLastError() then returns
WSAEWOULDBLOCK, nothing can be sent to that socket until the OnWrite event
occurs.  Any attempt to send data before that time will just produce more
WSAEWOULDBLOCK errors.


Gambit
Technical Details
Message-ID: <44440436$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44439c71$1@newsgroups.borland.com> <4443ca2a$1@newsgroups.borland.com> <4443d955$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,fea0b13af0f4efa8
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <44439c71$1@newsgroups.borland.com> <4443ca2a$1@newsgroups.borland.com> <4443d955$1@newsgroups.borland.com>
Subject: Re: TServerSocket SendText Exception
Date: Mon, 17 Apr 2006 14:10:14 -0700
Lines: 58
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: 68.69.17.41
Message-ID: <44440436$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1145308214 68.69.17.41 (17 Apr 2006 14:10:14 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail