Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Socket Programming Question (http://www.velocityreviews.com/forums/t443738-socket-programming-question.html)

Shaun Duncan 07-28-2006 11:59 PM

Socket Programming Question
 
Ok, so I'm not good with sockets, but I need some help. Every now and then,
when I call recv() to get the message sent by a client I wrote, it adds more
characters to the buffer than was indicated by the return value of recv().
Example, a particular call returns:

(53 -- 62): GET /images/mspaint.bmp HTTP/1.0 HOST: localhost:4210host:4210
(53 -- 62): GET /images/mspaint.bmp HTTP/1.0 HOST: localhost:4210host:4210
(47 -- 52): GET /document.txt HTTP/1.0 HOST: localhost:4210:4210

The first number is returned by recv() and the second is the value of
strlen() of the buffer. I'm stumped....any suggestions?

Thanks!



Shaun Duncan 07-29-2006 02:29 AM

Re: Socket Programming Question
 
"Shaun Duncan" <gtg179r@mail.gatech.edu> wrote in message
news:eae8do$d9r$1@news-int2.gatech.edu...
> <snip>


Looks like I figured it out...forgot to write '\0' to the end of the
buffer...d'oh!



Keith Thompson 07-29-2006 03:43 AM

Re: Socket Programming Question
 
"Shaun Duncan" <gtg179r@mail.gatech.edu> writes:
> "Shaun Duncan" <gtg179r@mail.gatech.edu> wrote in message
> news:eae8do$d9r$1@news-int2.gatech.edu...
>> <snip>

>
> Looks like I figured it out...forgot to write '\0' to the end of the
> buffer...d'oh!


Glad you solved it. In the future, be aware that standard C doesn't
support sockets; try comp.unix.programmer.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


All times are GMT. The time now is 08:38 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.