SCOUG Logo


Next Meeting: Sat, TBD
Meeting Directions


Be a Member
Join SCOUG

Navigation:


Help with Searching

20 Most Recent Documents
Search Archives
Index by date, title, author, category.


Features:

Mr. Know-It-All
Ink
Download!










SCOUG:

Home

Email Lists

SIGs (Internet, General Interest, Programming, Network, more..)

Online Chats

Business

Past Presentations

Credits

Submissions

Contact SCOUG

Copyright SCOUG



warp expowest
Pictures from Sept. 1999

The views expressed in articles on this site are those of their authors.

warptech
SCOUG was there!


Copyright 1998-2024, 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.

The Southern California OS/2 User Group
USA

SCOUG-Programming Mailing List Archives

Return to [ 02 | June | 1998 ]

<< Previous Message << >> Next Message >>


Date: Tue, 2 Jun 1998 09:44:36 PST8PDT
From: Steven Levine <steve53@earthlink.net >
Reply-To: scoug-programming@scoug.com
To: scoug-programming@scoug.com
Subject: SCOUG-Programming: GetLine()

In <199806021505.IAA09068@smtp.well.com>, on 06/02/98
at 07:37 AM, "Gregory W. Smith" said:

>char *GetLine(int Socket){

> static char Buffer[4096];
> int rc;
> int offset;

> rc = recv (Socket, Buffer, sizeof (Buffer), 0);

> if (rc > 0){
> if ( '\n' == Buffer[rc-1] ) {
> return &Buffer;
> } else {
> offset = rc;
> rc = recv (Socket, Buffer+offset, sizeof (Buffer)-offset, 0);
> return &Buffer;
> }
> } else {
> return NULL;
> }
>}

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.

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
-----------------------------------------------------------

=====================================================

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.