network programming - Need help in understanding the mapping of user-space send, sendto, sendmsg to kernel-space sendmsg -


I am trying to implement my own transport layer protocol in Linux for one experiment. I am going to use the socket interface and am integrating my protocol using sock_register. For Proto_ops I can see that parameters for sendmsg and recvmsg are struct (kiocb * iocb, struct socket * sock, struct msghdr * msg, size_t len, int flags). But sending three types of user APIs are sendto, sendmsg. Of these three, only SMSGG has the parameters of MSGDR. I think the other two APIs are incompatible with the kernel given to the kernel-space send mg functions by the kernel. So what happens when we send and send the U-Space API? I hope that I am clear ..

Thanks, Dada

Send () sendto () : is implemented in the context of Send (S, Buff, Lane, Flags); is equal to , sendto (s, buf), lane, flags, zero, 0);

sendto () in turn has been implemented in the context of sendmsg () . send (s, buff, lane, flags, eder, adr_len); has been implemented in the context of Userspace interface:

  struct iovec iov = {. Iov_base = buf, .iov_len = len}; Struct msghdr msg = {.msg_name = addr, .msg_namelen = addr_len, .msg_iov = & amp; Iov, .msg_iovlen = 1, .msg_control = NULL, .msg_controllen = 0}; Return Sensog (S, and MMS, Flag);  

The kernel space interface is slightly different - e.g. You get the kiocb parameter - but the original idea is the same as a send () or sendto () to sendmsg () < / Code> with a msghdr is converted to single iovec which references the buffer.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -