|
|
1.1 ! root 1: .TH SEND 2 "20 September 1983" ! 2: .UC 4 ! 3: .SH NAME ! 4: send, sendto, sendmsg \- send a message from a socket ! 5: .SH SYNOPSIS ! 6: .nf ! 7: .ft B ! 8: #include <sys/types.h> ! 9: #include <sys/socket.h> ! 10: .PP ! 11: .ft B ! 12: cc = send(s, msg, len, flags) ! 13: int cc, s; ! 14: char *msg; ! 15: int len, flags; ! 16: .PP ! 17: .ft B ! 18: cc = sendto(s, msg, len, flags, to, tolen) ! 19: int cc, s; ! 20: char *msg; ! 21: int len, flags; ! 22: struct sockaddr *to; ! 23: int tolen; ! 24: .PP ! 25: .ft B ! 26: cc = sendmsg(s, msg, flags) ! 27: int cc, s; ! 28: struct msghdr msg[]; ! 29: int flags; ! 30: .fi ! 31: .SH DESCRIPTION ! 32: .IR Send , ! 33: .IR sendto , ! 34: and ! 35: .I sendmsg ! 36: are used to transmit a message to another socket. ! 37: .I Send ! 38: may be used only when the socket is in a ! 39: .I connected ! 40: state, while ! 41: .I sendto ! 42: and ! 43: .I sendmsg ! 44: may be used at any time. ! 45: .PP ! 46: The address of the target is given by ! 47: .I to ! 48: with ! 49: .I tolen ! 50: specifying its size. ! 51: The length of the message is given by ! 52: .IR len . ! 53: If the message is too long to pass atomically through the ! 54: underlying protocol, then the error EMSGSIZE is returned, and ! 55: the message is not transmitted. ! 56: .PP ! 57: No indication of failure to deliver is implicit in a ! 58: .IR send . ! 59: Return values of \-1 indicate some locally detected errors. ! 60: .PP ! 61: If no messages space is available at the socket to hold ! 62: the message to be transmitted, then ! 63: .I send ! 64: normally blocks, unless the socket has been placed in ! 65: non-blocking i/o mode. ! 66: The ! 67: .IR select (2) ! 68: call may be used to determine when it is possible to ! 69: send more data. ! 70: .PP ! 71: The ! 72: .I flags ! 73: parameter may be set to MSG_OOB to send \*(lqout-of-band\*(rq ! 74: data on sockets which support this notion (e.g. SOCK_STREAM). ! 75: .PP ! 76: See ! 77: .IR recv (2) ! 78: for a description of the ! 79: .I msghdr ! 80: structure, of sending and receiving file descriptors in Unix domain via this ! 81: .I msghdr ! 82: structure, and of receiving out-of-band data. ! 83: .SH "RETURN VALUE ! 84: The call returns the number of characters sent, or \-1 ! 85: if an error occurred. ! 86: .SH "ERRORS ! 87: .TP 20 ! 88: [EBADF] ! 89: An invalid descriptor was specified. ! 90: .TP 20 ! 91: [ENOTSOCK] ! 92: The argument \fIs\fP is not a socket. ! 93: .TP 20 ! 94: [EFAULT] ! 95: An invalid user space address was specified for a parameter. ! 96: .TP 20 ! 97: [EMSGSIZE] ! 98: The socket requires that message be sent atomically, ! 99: and the size of the message to be sent made this impossible. ! 100: .TP 20 ! 101: [EWOULDBLOCK] ! 102: The socket is marked non-blocking and the requested operation ! 103: would block. ! 104: .SH SEE ALSO ! 105: recv(2), socket(2). See also bind(2) for address formats in different ! 106: communication domains. ! 107: .SH BUGS ! 108: Out-of-band data is only 1 character long.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.