UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2007-03-05 07:13 AM

reirei
Member
Registered: 2007-02-23
Posts: 6

Re: send() and recv() question

Offline

#2 2007-03-05 07:58 AM

yurec
Member
From: Singapore
Registered: 2006-11-16
Posts: 134

Re: send() and recv() question

if (recv(client_sock,buf,1,0) > 0){ - you probably wanted to write buf1

are you sure,that first string you send terminates with '\0'?

Offline

#3 2007-03-05 12:38 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: send() and recv() question

I'm guessing the problem must lie in the sending code...  Ie: it must really be
sending the letter "p" (0x70) for some reason...  Maybe "my_message1" isn't
null-terminated, so the strlen() doesn't work right, and you're reading off the end
of the buffer, and sending garbage characters? *shrug*  It's difficult to say without
seeing the source...  (And, if you post code, please post the ACTUAL code you're
using, rather than try to retype it, as you obviously did here...  Because, those
little snippets you posted won't even compile...  You typoed "ox" for "0x", and you
typoed "buf" for "buf1"...  In retyping like that, you're very likely to wipe out the
real bug, and make it impossible for use to help you spot it...)

Offline

#4 2007-03-05 05:57 PM

reirei
Member
Registered: 2007-02-23
Posts: 6

Re: send() and recv() question

Thanks for the replies.
Yeah I'll actually post the code net time. :P The buf is a typo, like you said.

Offline

Board footer

Powered by FluxBB