Networking Forums

Networking Forums > Computer Networking > Linux Networking > difference send and Write

Reply
Thread Tools Display Modes

difference send and Write

 
 
SaranJothy
Guest
Posts: n/a

 
      06-08-2007, 07:23 AM
Hullo,
In socket programming,i read send is similar to write, if flag is set
as 0 in send.
but I have seen one difference.
the retval is 0 in case of write and in case of send it is the number
of bytes sent (with flag zero)
Why so?

if (rval = write(msgsock, DATA, sizeof(DATA)) < 0){
printf("no. of bytes written %d\n",rval); // zero here
if((rval = send(msgsock,DATA,sizeof(DATA),0)) < 0){
printf("no. of bytes written %d\n",rval); // sizeof(DATA) here

One more question.
Is the return value indicates the number of bytes send on wire OR
number of bytes copied to kernel send buffer?

NOTE: this is for SOCK_STREAM socket in linux 2.6
Thanks.

 
Reply With Quote
 
 
 
 
Robert Harris
Guest
Posts: n/a

 
      06-08-2007, 07:55 AM
SaranJothy wrote:
> Hullo,
> In socket programming,i read send is similar to write, if flag is set
> as 0 in send.
> but I have seen one difference.
> the retval is 0 in case of write and in case of send it is the number
> of bytes sent (with flag zero)
> Why so?


It isn't true; write() returns the number of bytes written (if it writes
bytes).

Robert

>
> if (rval = write(msgsock, DATA, sizeof(DATA)) < 0){
> printf("no. of bytes written %d\n",rval); // zero here
> if((rval = send(msgsock,DATA,sizeof(DATA),0)) < 0){
> printf("no. of bytes written %d\n",rval); // sizeof(DATA) here
>
> One more question.
> Is the return value indicates the number of bytes send on wire OR
> number of bytes copied to kernel send buffer?
>
> NOTE: this is for SOCK_STREAM socket in linux 2.6
> Thanks.
>

 
Reply With Quote
Reply

Thread Tools
Display Modes

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
Time to write to BT.... Gordon Hudson Broadband 8 03-03-2007 08:46 PM
Can we write our own shell?? bobby Linux Networking 6 11-09-2006 04:12 PM
write grumpyoldhori Wireless Internet 1 06-09-2006 01:06 PM
TCP write error Captain Dondo Linux Networking 2 03-01-2006 11:48 PM
NFS write errors John Stolz Linux Networking 0 05-26-2004 05:11 PM



1 2 3 4 5 6 7 8 9 10 11