Find the answer to your Linux question:
Results 1 to 5 of 5
Iperf client calls write() to send a message to iperf server. My aim - is to find out the way the information goes thru the kernel. First of all, i ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    3

    write() method for sockets in kernel


    Iperf client calls write() to send a message to iperf server. My aim - is to find out the way the information goes thru the kernel. First of all, i wanna find write method for sockets. it's something like that
    Code:
    int             (*sendmsg)   (struct kiocb *iocb, struct socket *sock,
                                          struct msghdr *m, size_t total_len);
    Could u please help me?

  2. #2
    Just Joined!
    Join Date
    Feb 2008
    Posts
    7
    well, write() is the system call, which takes fd (ie. file descriptor) as one of the arguments. you can get the code of write() system call in <kernel_source_dir>/fs/open.c (i guess) and the function name would be sys_write().. now depending upon the file descriptor, kernel will identify that its a regular file descriptor or a socket descriptor. once it finds that the descriptor is socket, it will call the socket's write method, which will be pointing to "sendmsg".. i hope this helps..

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    3
    Thank you for your answer)))
    I'll try to find socket's sendmsg method that way

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Feb 2008
    Posts
    3
    Quote Originally Posted by vthanki View Post
    well, write() is the system call, which takes fd (ie. file descriptor) as one of the arguments. you can get the code of write() system call in <kernel_source_dir>/fs/open.c (i guess) and the function name would be sys_write().. now depending upon the file descriptor, kernel will identify that its a regular file descriptor or a socket descriptor. once it finds that the descriptor is socket, it will call the socket's write method, which will be pointing to "sendmsg".. i hope this helps..
    there is no method like write() in open.c

  6. #5
    Just Joined!
    Join Date
    Feb 2008
    Posts
    7
    sorry about that.. u'll find it in fs/read_write.c (as u mentioned).. method name would be sys_write() (sys_<name>) is the convention for syscalls in linux..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •