Architecture/Lecture/read write vs send receive

From Apache OpenOffice Wiki
Jump to: navigation, search

read/write are not portable recv/send are

while calling read/write on sockets in unices is perfectly ok because "everything in Unix is a file" and therefor a socket is also represented as a file descriptor, this is not the case for Windows. (the equivalent functions here would be ReadFile() and WriteFile() ) Basically in Windows socket functions create socket handles, which are disjoint from the file descriptor system.

on a minor note there is an additional parameter to provide for recv/send which specifies the type of message reception

  • MSG_PEEK Peeks at an incoming message. The data is treated as unread and the next recv() or similar function shall still return this data.
  • MSG_OOB Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific.
  • MSG_WAITALL on SOCK_STREAM sockets this requests that the function block until the full amount of data can be returned. The function may return a smaller amount of data if the socket is a message-based socket, if a signal is caught, if the connection is terminated, if MSG_PEEK was specified, or if an error is pending for the socket.
Personal tools