Socket Programming Question

S

Shaun Duncan

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

Keith Thompson

Shaun Duncan said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Java socket programming 1
mingw socket programming 3
socket programming 8
Minimum Total Difficulty 0
Receive packet using socket 2
python socket query 4
socket 5
One more socket programming question 2

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top