|
|
1.1 ! root 1: .\" Copyright (c) 1983 The Regents of the University of California. ! 2: .\" All rights reserved. ! 3: .\" ! 4: .\" Redistribution and use in source and binary forms are permitted provided ! 5: .\" that: (1) source distributions retain this entire copyright notice and ! 6: .\" comment, and (2) distributions including binaries display the following ! 7: .\" acknowledgement: ``This product includes software developed by the ! 8: .\" University of California, Berkeley and its contributors'' in the ! 9: .\" documentation or other materials provided with the distribution and in ! 10: .\" all advertising materials mentioning features or use of this software. ! 11: .\" Neither the name of the University nor the names of its contributors may ! 12: .\" be used to endorse or promote products derived from this software without ! 13: .\" specific prior written permission. ! 14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 17: .\" ! 18: .\" @(#)send.2 6.6 (Berkeley) 6/23/90 ! 19: .\" ! 20: .TH SEND 2 "June 23, 1990" ! 21: .UC 5 ! 22: .SH NAME ! 23: send, sendto, sendmsg \- send a message from a socket ! 24: .SH SYNOPSIS ! 25: .nf ! 26: .ft B ! 27: #include <sys/types.h> ! 28: #include <sys/socket.h> ! 29: .PP ! 30: .ft B ! 31: cc = send(s, msg, len, flags) ! 32: int cc, s; ! 33: char *msg; ! 34: int len, flags; ! 35: .PP ! 36: .ft B ! 37: cc = sendto(s, msg, len, flags, to, tolen) ! 38: int cc, s; ! 39: char *msg; ! 40: int len, flags; ! 41: struct sockaddr *to; ! 42: int tolen; ! 43: .PP ! 44: .ft B ! 45: cc = sendmsg(s, msg, flags) ! 46: int cc, s; ! 47: struct msghdr *msg; ! 48: int flags; ! 49: .fi ! 50: .SH DESCRIPTION ! 51: .IR Send , ! 52: .IR sendto , ! 53: and ! 54: .I sendmsg ! 55: are used to transmit a message to another socket. ! 56: .I Send ! 57: may be used only when the socket is in a ! 58: .I connected ! 59: state, while ! 60: .I sendto ! 61: and ! 62: .I sendmsg ! 63: may be used at any time. ! 64: .PP ! 65: The address of the target is given by ! 66: .I to ! 67: with ! 68: .I tolen ! 69: specifying its size. ! 70: The length of the message is given by ! 71: .IR len . ! 72: If the message is too long to pass atomically through the ! 73: underlying protocol, then the error EMSGSIZE is returned, and ! 74: the message is not transmitted. ! 75: .PP ! 76: No indication of failure to deliver is implicit in a ! 77: .IR send . ! 78: Return values of \-1 indicate some locally detected errors. ! 79: .PP ! 80: If no messages space is available at the socket to hold ! 81: the message to be transmitted, then ! 82: .I send ! 83: normally blocks, unless the socket has been placed in ! 84: non-blocking I/O mode. ! 85: The ! 86: .IR select (2) ! 87: call may be used to determine when it is possible to ! 88: send more data. ! 89: .PP ! 90: The ! 91: .I flags ! 92: parameter may include one or more of the following: ! 93: .PP ! 94: .nf ! 95: .RS ! 96: .ta \w'#define\ \ 'u +\w'MSG_DONTROUTE\ \ \ 'u +\w'0x\0\0\0\ \ 'u ! 97: #define MSG_OOB 0x1 /* process out-of-band data */ ! 98: #define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */ ! 99: .RE ! 100: .fi ! 101: The flag MSG_OOB is used to send \*(lqout-of-band\*(rq ! 102: data on sockets that support this notion (e.g. SOCK_STREAM); ! 103: the underlying protocol must also support \*(lqout-of-band\*(rq data. ! 104: MSG_DONTROUTE is usually used only by diagnostic or routing programs. ! 105: .PP ! 106: See ! 107: .IR recv (2) ! 108: for a description of the ! 109: .I msghdr ! 110: structure. ! 111: .SH "RETURN VALUE ! 112: The call returns the number of characters sent, or \-1 ! 113: if an error occurred. ! 114: .SH "ERRORS ! 115: .TP 20 ! 116: [EBADF] ! 117: An invalid descriptor was specified. ! 118: .TP 20 ! 119: [ENOTSOCK] ! 120: The argument \fIs\fP is not a socket. ! 121: .TP 20 ! 122: [EFAULT] ! 123: An invalid user space address was specified for a parameter. ! 124: .TP 20 ! 125: [EMSGSIZE] ! 126: The socket requires that message be sent atomically, ! 127: and the size of the message to be sent made this impossible. ! 128: .TP 20 ! 129: [EWOULDBLOCK] ! 130: The socket is marked non-blocking and the requested operation ! 131: would block. ! 132: .TP 20 ! 133: [ENOBUFS] ! 134: The system was unable to allocate an internal buffer. ! 135: The operation may succeed when buffers become available. ! 136: .TP 20 ! 137: [ENOBUFS] ! 138: The output queue for a network interface was full. ! 139: This generally indicates that the interface has stopped sending, ! 140: but may be caused by transient congestion. ! 141: .SH SEE ALSO ! 142: fcntl(2), recv(2), select(2), getsockopt(2), socket(2), write(2)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.