Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: client-server data transfers appended with funny characters
thanks a lot!!

I just tried different ways, if I do the following
 

rather than
 
or 

Then, it is working fine. But I still don't quite understand the
rationale, because I thought strlen(recvBuf)+1 already represents the
packet length. 100 is the maximum length of the packet that I defined
for the recvBuf variable.

please advise. thanks!!

Report this thread to moderator Post Follow-up to this message
Old Post
Matt
07-12-04 08:57 AM


Re: client-server data transfers appended with funny characters
On 11 Jul 2004 22:50:14 -0700, Matt <jrefactors@hotmail.com> wrote:

> thanks a lot!!
>
> I just tried different ways, if I do the following
> 
> rather than
> 
> or 
>
> Then, it is working fine. But I still don't quite understand the
> rationale, because I thought strlen(recvBuf)+1 already represents the
> packet length. 100 is the maximum length of the packet that I defined
> for the recvBuf variable.
>

No, how can strlen(recvBuf)+1 represent the packet length when
strlen(recvBuf)+1 is called *before* you received the packet? At best
strlen(recvBuf)+1 will be the length of the *last* packet you received not
the packet you are *about* to receive.

In any case recv does not need to know the packet length, you've got that
wrong. It does need to know the size of the buffer you have given it
(which is nothing to do with the packet length). In your case the size of
the buffer is 100 bytes, so that is what you should put for the third
argument.

*After* you have called recv, then you have a packet, and then (depending
on what you sent) is might be sensible to call strlen(recvBuf)+1 to find
out how big the packet is. Although I think rVal will tell you the same
information.

But think about it, you cannot find out how long a packet is until *after*
you have received the packet, that seems obvious.

john

Report this thread to moderator Post Follow-up to this message
Old Post
John Harrison
07-12-04 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C++ archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 11:33 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.