SCOUG-Programming Mailing List Archives
Return to [ 02 |
June |
1998 ]
<< Previous Message <<
>> Next Message >>
Content Type: text/plain
-----BEGIN PGP SIGNED MESSAGE-----
On Tue, 2 Jun 1998 09:44:36 PST8PDT, Steven Levine wrote:
>Time for my 2cents. The above only fixes part of the problem and can
>return a buffer without and NL to the caller. The "specifications" don't
>say if the caller must handle this.
That was the obvious problem that I referred to. A slow typist could
cause the send command to be invoked more than twice depending
on the client. Type the command.... Go look up the options. Type
the options.... Go look at a file listing. Type the file name.... Answer the
phone. Then hit return. It is conceivable that send() could be invoked
during each pause.
>
>char *GetLine(int Socket){
>
> static char Buffer[4096];
> int rc = 0;
> int offset = 0;
>
> while (rc >= 0 && offset < sizeof(Buffer)){
>
> rc = recv (Socket, Buffer + offset, sizeof (Buffer) - offset,
>0);
>
> if (rc > 0) {
> if ( '\n' == Buffer[offset+rc-1] )
> return Buffer;
> else
> offset += rc;
> }
> }
>
> return NULL; /* No NL or recv failed */
>}
>
>What's left is to decide how many times we allow recv to return no data
>before giving up.
>
>Steven
>
>--
>-----------------------------------------------------------
>Steven Levine MR2/ICE #10183
>-----------------------------------------------------------
===============================================================
Gregory W. Smith (WD9GAY) gsmith@well.com
finger gsmith@well.com for PGP public key
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBNXRdlDtML4mvizAhAQEc6AQAvZkSZG0w7755yxCGCJvCSQoGCTZpp6AX
nBdvnv43B85ugWkZIPD4AqruDnomUASUv2gYVzjCF+JP/qNVci+dG/q/RKxH1flk
MMw7G0ho+No3N79P0I/8oyPiug3nANNQxk03idvjzQXEh+cWPhrNJb8Zyizm7DGp
r5julTWoOQw=
=idpw
-----END PGP SIGNATURE-----
=====================================================
To unsubscribe from this list, send an email message
to "steward@scoug.com". In the body of the message,
put the command "unsubscribe scoug-programming".
For problems, contact the list owner at
"rollin@scoug.com".
=====================================================
<< Previous Message <<
>> Next Message >>
Return to [ 02 |
June |
1998 ]
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|