I have downloaded the sytem source code from here, but i can't find source code of read/write functions from the package. Could anybody tell me where I can get the code for these socket operation functions?
[why I want to check the source code]
I am developing a multithreaded linux application and need to know, if calling socket operation functions like write/read/sendmsg to access a same TCP socket from different threads concurrently is safe or not.
you can search a function and other things in the kernel source code on LXR.
But before you search, you should know that write/read/sendmsg are system call,and their definitions aren't like usually functions. When you use read(), sys_read() works in fact,and itselves defintion is also confused:here
here is write() and sendmsg() .
If you want to know more about system call such as their definiton, you can read chapter.5 of Linux Kernel Development.
1) Find out what library provides function you want to see source of
e.g. "man read"
NAME
read - read from a file descriptor
SYNOPSIS
#include <unistd.h>
ssize_t read(int fd, void *buf, size_t count);
2) locate header file, e.g. "/usr/include/unistd.h"
3) find out what package provides this file, with Debian/Ubuntu e.g.
pwadas@kehillah:~$ dpkg -S /usr/include/unistd.h
libc6-dev: /usr/include/unistd.h
4) Download source package and browse code
there's probably many "read" functions available from various libraries. You might want to try
man 7 socket
man 7 tcp
or other relevant sources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With