Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Socket Programming Question

Reply
Thread Tools

Socket Programming Question

 
 
Shaun Duncan
Guest
Posts: n/a
 
      07-28-2006
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!


 
Reply With Quote
 
 
 
 
Shaun Duncan
Guest
Posts: n/a
 
      07-29-2006
"Shaun Duncan" <(E-Mail Removed)> wrote in message
news:eae8do$d9r$(E-Mail Removed)...
> <snip>


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


 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      07-29-2006
"Shaun Duncan" <(E-Mail Removed)> writes:
> "Shaun Duncan" <(E-Mail Removed)> wrote in message
> news:eae8do$d9r$(E-Mail Removed)...
>> <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) http://www.velocityreviews.com/forums/(E-Mail Removed) <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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 1 02-03-2009 06:20 AM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 0 02-01-2009 12:45 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM



Advertisments