LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Using write fn for sockets in both BSD and Linux (http://www.linuxquestions.org/questions/programming-9/using-write-fn-for-sockets-in-both-bsd-and-linux-242876/)

trotters78 10-15-2004 03:37 AM

Using write fn for sockets in both BSD and Linux
 
Hi,

With reference to the book UNIX Network Programming by W.Richard Stevens:

In section 17.3 under "Step to next socket address structure".

/******************************************************

The author stated that :
" For example if we are deleting a route, a return of 0 from write means sucess, while an error return of ESRCH means the route could not be found."

*******************************************************/

Using the same scenario, I tried to delete a non existance route.
I have tried it on both FreeBSD and Linux using Netlink sockets and routing sockets respectively.

ret = write(sk, rtm, all_size);

FreeBSD's "WRITE function" returns a -1 and errno = ESRCH.
Linux's "WRITE function" returns the lenght of data sent and errno = 0.
But the nlmsgerr acknowledged from Linux contains the correct errno.

It is obvious that Linux is aware of the error.
But why is it that Linux "WRITE function" does not reflect the error?


I will be happy to re-explain my question.
Any help rendered will be helpful.
Thanks in advance.


Daryl


All times are GMT -5. The time now is 03:27 PM.