os/ossrv/genericopenlibs/openenvcore/include/sys/socket.dosc
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /** @file  ../include/sys/socket.h
     2 @internalComponent
     3 */
     4 
     5 /** @fn  accept(int s, struct sockaddr *  addr, socklen_t *  addrlen)
     6 @param s
     7 @param addr
     8 @param addrlen
     9 
    10   The argument s is a socket that has been created with socket, bound to an address with bind and is listening for connections after a listen . The accept system call extracts the first connection request on the queue 
    11 of pending connections and creates a new socket which it allocates a new file 
    12 descriptor. The new socket inherits the state of the O_NONBLOCK property from the original socket s.
    13 
    14  If no pending connections are present on the queue, and the original socket 
    15   is not marked as non-blocking, accept blocks the caller until a connection is present. If the original 
    16   socket is marked non-blocking and no pending connections are present on the 
    17   queue, accept returns an error as described below.
    18 
    19  The accepted socket may not be used to accept more connections. The original 
    20   socket s remains open.
    21 
    22  The argument addr is a result argument that is filled-in with the address of the 
    23   connecting entity as it is known to the communications layer. The exact format 
    24   of the addr argument is determined by the domain in which the communication 
    25   is occurring. A null pointer may be specified for addr if the address information is not required. In this case addrlen is not used and should also be null. Otherwise, the addrlen argument is a value-result argument: It should initially contain 
    26   the amount of space pointed to by addr and on return will contain the actual length (in bytes) of the 
    27   address returned. This call is used with connection-based socket types, currently 
    28   with SOCK_STREAM.
    29 
    30  It is possible to select a socket for the purposes of doing an accept by selecting it for read.
    31 
    32  For certain protocols, such as ISO or DATAKIT which require an explicit confirmation, accept can be thought of as merely dequeueing the next connection 
    33   request and not implying confirmation. Confirmation can be implied by a normal 
    34   read or write on the new file descriptor, and rejection can be implied by closing 
    35   the new socket.
    36 
    37 Examples:
    38 @code
    39 #include <sys/socket.h>
    40 #include <netinet/in.h>
    41 #include <unistd.h>
    42 void GetSockName()
    43 {
    44    int sock_fd;
    45    int newsock_fd;
    46    struct sockaddr_in addr;
    47    struct sockaddr_in ss;
    48    struct sockaddr_in new_socket;
    49    unsigned int len;
    50    unsigned int addr_len;
    51    
    52    sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    53        
    54    addr.sin_family = AF_INET;
    55    addr.sin_addr.s_addr = htonl(INADDR_ANY);
    56    addr.sin_port = htons(5000);
    57    bind(sock_fd,(sockaddr*)&addr;,sizeof(addr));
    58    listen(sock_fd,1);
    59    newsock_fd = accept(sock_fd,(sockaddr*)&new;_socket,&addr;_len); // Code blocks here
    60    if (newsock_fd <= 0)
    61    {
    62                 perror("accept:");
    63    }
    64    close(newsock_fd);
    65    close(sock_fd);
    66 }
    67 
    68 @endcode
    69 @return   The call returns -1 on error.
    70 If it succeeds, it returns a non-negative
    71 integer that is a descriptor for the accepted socket.
    72 
    73 @see bind()
    74 @see connect()
    75 @see getpeername()
    76 @see listen()
    77 @see select()
    78 @see socket()
    79 
    80 
    81 
    82 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
    83 
    84 @publishedAll
    85 @externallyDefinedApi
    86 */
    87 
    88 
    89 /** @fn  bind(int s, const struct sockaddr *addr, socklen_t addrlen)
    90 @param s
    91 @param addr
    92 @param addrlen
    93 
    94   The bind system call
    95 assigns the local protocol address to a socket.
    96 When a socket is created
    97 with socket it exists in an address family space but has no protocol address assigned.
    98 The bind system call requests that addr be assigned to the socket.
    99 
   100 Examples:
   101 @code
   102 #include <sys/socket.h>
   103 #include <netinet/in.h>
   104 #include <unistd.h>
   105 TInt GetSockName()
   106 {
   107    int sock_fd;
   108    struct sockaddr_in addr,ss;
   109    unsigned int len;   
   110    
   111    sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   112        
   113    addr.sin_family = AF_INET;
   114    addr.sin_addr.s_addr = htonl(INADDR_ANY);
   115    addr.sin_port = htons(5000);
   116    bind(sock_fd,(struct sockaddr*)&addr;,sizeof(addr));
   117    close(sock_fd);
   118 }
   119 
   120 @endcode
   121 
   122 Notes:
   123 
   124  For maximum portability always initialise the socket address structure to 
   125   zero before populating it and passing it to bind.
   126   
   127 @return   The bind() function returns the value 0 if successful; otherwise the
   128 value -1 is returned and the global variable errno is set to indicate the
   129 error.
   130 
   131 @see connect()
   132 @see getsockname()
   133 @see listen()
   134 @see socket()
   135 
   136 
   137  
   138 
   139 @publishedAll
   140 @externallyDefinedApi
   141 */
   142 
   143 /** @fn  connect(int s, const struct sockaddr *name, socklen_t namelen)
   144 @param s
   145 @param name
   146 @param namelen
   147  
   148 
   149  The s argument is a socket. If it is of type SOCK_DGRAM name specifies the peer with which the socket is to be associated. It 
   150   specifiies the address to which datagrams are to be sent and the only address 
   151   from which datagrams are to be received.
   152 
   153  If the socket is of type SOCK_STREAM, this call attempts to make a connection to another socket. 
   154   The other socket is specified by name, which is an address in the communications space of the socket. 
   155   Each communications space interprets the name argument in its own way.
   156 
   157  Generally, stream sockets may successfully connect only once and datagram sockets may use connect multiple times to change their association. Datagram sockets 
   158   may dissolve the association by connecting to an invalid address, such as a 
   159   null address.
   160 
   161 Examples:
   162 @code
   163 #include <sys/socket.h>
   164 #include <netinet/in.h>
   165 #include <unistd.h>
   166 void Connect()
   167 {
   168    struct sockaddr_in serv_addr;
   169    int sock_fd;
   170    serv_addr.sin_family = AF_INET;
   171    serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   172    serv_addr.sin_port = htons(5000);
   173    sock_fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
   174    connect(sock_fd,(struct sockaddr*)&serv;_addr,sizeof(serv_addr));
   175    
   176    close(sock_fd);
   177 }
   178 
   179 @endcode
   180 @return   The connect() function returns the value 0 if successful; otherwise it returns 
   181 the value -1 and the sets global variable errno to indicate the error.
   182 
   183 @see accept()
   184 @see getpeername()
   185 @see getsockname()
   186 @see select()
   187 @see socket()
   188 
   189 
   190 
   191 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
   192 
   193 @publishedAll
   194 @externallyDefinedApi
   195 */
   196 
   197 
   198 /** @fn  getpeername(int s, struct sockaddr *  name, socklen_t *  namelen)
   199 @param s
   200 @param name
   201 @param namelen
   202 @return   The getpeername() function returns the value 0 if successful; otherwise
   203 the value -1 is returned and the global variable errno is set to indicate
   204 the error.
   205 
   206   The getpeername system call
   207 returns the name of the peer connected to
   208 socket s. The namelen argument should be initialized to indicate
   209 the amount of space pointed to by name. On return it contains the actual size of the name
   210 returned (in bytes).
   211 The name is truncated if the buffer provided is too small.
   212 
   213 Examples:
   214 @code
   215 #include <sys/socket.h>
   216 #include <netinet/in.h>
   217 #include <unistd.h>
   218 void GetSockName()
   219 {
   220    int sock_fd;
   221    int newsock_fd;
   222    struct sockaddr_in addr;
   223    struct sockaddr_in ss;
   224    struct sockaddr_in new_socket;
   225    unsigned int len;
   226    unsigned int addr_len;
   227     
   228    sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   229        
   230    addr.sin_family = AF_INET;
   231    addr.sin_addr.s_addr = htonl(INADDR_ANY);
   232    addr.sin_port = htons(5000);
   233    bind(sock_fd,(struct sockaddr*)&addr;,sizeof(addr));
   234    listen(sock_fd,1);
   235    newsock_fd = accept(sock_fd,(struct sockaddr*)&new;_socket,&addr;_len); // Code blocks here
   236   
   237    // Assuming client has connected to the server. 
   238    len = sizeof(ss);
   239    getpeername(sock_fd,(struct sockaddr*)&ss;,&len;);
   240    close(newsock_fd);
   241    close(sock_fd);
   242  }
   243 
   244 @endcode
   245 @see accept()
   246 @see bind()
   247 @see getsockname()
   248 @see socket()
   249 
   250 
   251  
   252 
   253 @publishedAll
   254 @externallyDefinedApi
   255 */
   256 
   257 
   258 /** @fn  getsockname(int s, struct sockaddr *  name, socklen_t *  namelen)
   259 @param s
   260 @param name
   261 @param namelen
   262 @return   The getsockname() function returns the value 0 if successful; otherwise
   263 the value -1 is returned and the global variable errno is set to indicate
   264 the error.
   265 
   266   The getsockname system call
   267 returns the current name for the specified socket.
   268 The namelen argument should be initialized to indicate
   269 the amount of space pointed to by name. On return it contains the actual size of the name
   270 returned (in bytes).
   271 
   272 Examples:
   273 @code
   274 #include <sys/socket.h>
   275 #include <netinet/in.h>
   276 #include <unistd.h>
   277 TInt GetSockName()
   278 {
   279    int sock_fd;
   280    struct sockaddr_in addr,ss;
   281    unsigned int len;   
   282    
   283    sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   284        
   285    addr.sin_family = AF_INET;
   286    addr.sin_addr.s_addr = htonl(INADDR_ANY);
   287    addr.sin_port = htons(5000);
   288    bind(sock_fd,(struct sockaddr*)&addr;,sizeof(addr));
   289  
   290   len=sizeof(ss);
   291   getsockname(sock_fd,(struct sockaddr*)&ss;,&len;);
   292   close(sock_fd);
   293 }
   294 
   295 @endcode
   296 @see bind()
   297 @see getpeername()
   298 @see socket()
   299 
   300 
   301  
   302 
   303 @publishedAll
   304 @externallyDefinedApi
   305 */
   306 
   307 /** @fn  getsockopt(int s, int level, int optname, void *  optval, socklen_t *  optlen)
   308 @param s
   309 @param level
   310 @param optname
   311 @param optval
   312 @param optlen
   313 Note: This description also covers the following functions -
   314  setsockopt() 
   315 
   316 @return   Upon successful completion, the value 0 is returned; otherwise the
   317 value -1 is returned and the global variable errno is set to indicate the
   318 error.
   319 
   320 The getsockopt and setsockopt system calls manipulate the options associated with a socket. Options may exist at multiple protocol levels; they are always present at the uppermost "socket" level. 
   321 When manipulating socket options the level at which the option resides and the name of the option must be specified. To manipulate options at the socket level, level is specified as SOL_SOCKET. To manipulate options at any other level the protocol number of the appropriate protocol controlling the option is supplied. For example, to indicate that an option is to be interpreted by the TCP protocol, level should be set to the protocol number of TCP; 
   322 
   323 The optval and optlen arguments are used to access option values for setsockopt. For getsockopt they identify a buffer in which the value for the requested option(s) are to be returned. For getsockopt, optlen is a value-result argument, initially containing the size of the buffer pointed to by optval, and modified on return to indicate the actual size of the value returned. If no option value is to be supplied or returned, optval may be NULL. 
   324 
   325 The optname argument and any specified options are passed uninterpreted to the appropriate protocol module for interpretation. The include file   \#include \<sys/socket.h\>contains definitions for socket level options, described below. Options at other protocol levels vary in format and name; consult the appropriate entries in section 4 of the manual. 
   326 Most socket-level options utilize an int argument for optval. For setsockopt, the argument should be non-zero to enable a boolean option, or zero if the option is to be disabled. SO_LINGER uses a struct linger argument, defined in 
   327  @code
   328   #include <sys/socket.h,> which specifies the desired state of the option and the linger interval (see below). SO_SNDTIMEO and SO_RCVTIMEO use a struct timeval argument, defined in  
   329   #include <sys/time.h.> 
   330 The following options are recognized at the socket level. Except as noted, each may be examined with getsockopt and set with setsockopt. SO_DEBUG            enables recording of debugging information 
   331 SO_REUSEADDR       Allows a socket to be bound to an local address that is already in use. 
   332 SO_REUSEPORT       enables duplicate address and port bindings 
   333 SO_KEEPALIVE       enables keep connections alive 
   334 SO_DONTROUTE       enables routing bypass for outgoing messages 
   335 SO_BROADCAST       enables permission to transmit broadcast messages (enable only)
   336 SO_OOBINLINE       enables reception of out-of-band data in band 
   337 SO_SNDBUF          set buffer size for output 
   338 SO_RCVBUF          set buffer size for input 
   339 SO_SNDLOWAT        set minimum count for output 
   340 SO_RCVLOWAT        set minimum count for input 
   341 SO_SNDTIMEO        set timeout value for output 
   342 SO_RCVTIMEO        set timeout value for input 
   343 SO_ACCEPTFILTER            set accept filter on listening socket 
   344 SO_TYPE            get the type of the socket (get only) 
   345 SO_ERROR           get and clear error on the socket (get only)  
   346    
   347 
   348 @endcode
   349 
   350 SO_DEBUG enables debugging in the underlying protocol modules. SO_REUSEADDR indicates that the rules used in validating addresses supplied in a bind system call should allow reuse of local addresses. SO_REUSEPORT allows completely duplicate bindings by multiple processes if they all set SO_REUSEPORT before binding the port. This option permits multiple instances of a program to each receive UDP/IP multicast or broadcast datagrams destined for the bound port. SO_KEEPALIVE enables the periodic transmission of messages on a connected socket. SO_DONTROUTE indicates that outgoing messages should bypass the standard routing facilities. Instead, messages are directed to the appropriate network interface according to the network portion of the destination address. 
   351 
   352 The option SO_BROADCAST requests permission to send broadcast datagrams on the socket. Broadcast was a privileged operation in earlier versions of the system. With protocols that support out-of-band data, the SO_OOBINLINE option requests that out-of-band data be placed in the normal data input queue as received; it will then be accessible with recv or read calls without the MSG_OOB flag. Some protocols always behave as if this option is set. SO_SNDBUF and SO_RCVBUF are options to adjust the normal buffer sizes allocated for output and input buffers, respectively. The buffer size may be increased for high-volume connections, or may be decreased to limit the possible backlog of incoming data. The system places an absolute maximum on these values, which is accessible through the sysctl MIB variable "kern.ipc.maxsockbuf." 
   353 
   354 SO_SNDLOWAT is an option to set the minimum count for output operations. Most output operations process all of the data supplied by the call, delivering data to the protocol for transmission and blocking as necessary for flow control. Nonblocking output operations will process as much data as permitted subject to flow control without blocking, but will process no data if flow control does not allow the smaller of the low water mark value or the entire request to be processed. A select operation testing the ability to write to a socket will return true only if the low water mark amount could be processed. The default value for SO_SNDLOWAT is set to a convenient size for network efficiency, often 1024. SO_RCVLOWAT is an option to set the minimum count for input operations. In general, receive calls will block until any (non-zero) amount of data is received, then return with the smaller of the amount available or the amount requested. The default value for SO_RCVLOWAT is 1. If SO_RCVLOWAT is set to a larger value, blocking receive calls normally wait until they have received the smaller of the low water mark value or the requested amount. 
   355 
   356 SO_SNDTIMEO is an option to set a timeout value for output operations. It accepts a struct timeval argument with the number of seconds and microseconds used to limit waits for output operations to complete. If a send operation has blocked for this much time, it returns with a partial count or with the error EWOULDBLOCK if no data were sent. In the current implementation, this timer is restarted each time additional data are delivered to the protocol, implying that the limit applies to output portions ranging in size from the low water mark to the high water mark for output. SO_RCVTIMEO is an option to set a timeout value for input operations. It accepts a struct timeval argument with the number of seconds and microseconds used to limit waits for input operations to complete. In the current implementation, this timer is restarted each time additional data are received by the protocol, and thus the limit is in effect an inactivity timer. If a receive operation has been blocked for this much time without receiving additional data, it returns with a short count or with the error EWOULDBLOCK if no data were received. 
   357 
   358 SO_ACCEPTFILTER places an accept_filter on the socket, which will filter incoming connections on a listening stream socket before being presented for accept. Once more, listen must be called on the socket before trying to install the filter on it, or else the setsockopt system call will fail. 
   359 
   360 SO_LINGER option is not supported by this api.
   361 
   362 @code
   363 struct  accept_filter_arg {
   364         char    af_name[16];
   365         char    af_arg[256-16];
   366 };
   367 @endcode
   368 
   369 
   370 
   371 The optval argument should point to a struct accept_filter_arg that will select and configure the accept_filter. The af_name argument should be filled with the name of the accept filter that the application wishes to place on the listening socket. The optional argument af_arg can be passed to the accept filter specified by af_name to provide additional configuration options at attach time. Passing in an optval of NULL will remove the filter. 
   372 
   373 Finally, SO_TYPE and SO_ERROR are options used only with getsockopt. SO_TYPE returns the type of the socket, such as SOCK_STREAM; it is useful for servers that inherit sockets on startup. SO_ERROR returns any pending error on the socket and clears the error status. It may be used to check for asynchronous errors on connected datagram sockets or for other asynchronous errors. 
   374  
   375 
   376 
   377 
   378 Examples:
   379 @code
   380 #include <sys/socket.h>
   381 #include <netinet/in.h>
   382 #include <unistd.h>
   383 void SocketOptions()
   384 {
   385    int sock_fd;
   386    int optval = 1;
   387    unsigned int optlen = sizeof(optval);
   388    int rdoptval;
   389    sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   390    setsockopt(sock_fd,SOL_SOCKET,SO_KEEPALIVE,&optval;,optlen);
   391    getsockopt(sock_fd,SOL_SOCKET,SO_KEEPALIVE,(void*)&rdoptval;,&optlen;);
   392 close(sock_fd);
   393 }
   394 
   395 @endcode
   396 @see ioctl()
   397 @see socket()
   398 
   399 
   400  
   401 
   402 @publishedAll
   403 @externallyDefinedApi
   404 */
   405 
   406 /** @fn  listen(int fd, int n)
   407 @param fd
   408 @param n
   409 @return   The listen() function returns the value 0 if successful; otherwise the
   410 value -1 is returned and the global variable errno is set to indicate the
   411 error.
   412 
   413   To accept connections a socket is first created with socket . A willingness to accept incoming connections 
   414 and a queue limit for incoming connections are specified with listen and then the connections are accepted with accept . The listen system call applies only to sockets of type SOCK_STREAM or SOCK_SEQPACKET.
   415 
   416  The n argument defines the maximum length the queue of pending connections 
   417   may grow to. The real maximum queue length will be 1.5 times more than the value 
   418   specified in the n argument. A subsequent listen system call on the listening socket allows the caller to change 
   419   the maximum queue length using a new n argument. If a connection request arrives with the queue full 
   420   the client may receive an error with an indication of ECONNREFUSED , or, in the case of TCP, the connection will be silently 
   421   dropped.
   422 
   423  Note that before BSD 4.5 and the introduction of the syncache the n argument also determined the length of the incomplete connection 
   424   queue, which held TCP sockets in the process of completing TCP's 3-way 
   425   handshake. These incomplete connections are now held entirely in the syncache, 
   426   which is unaffected by queue lengths. Inflated n values to help handle denial of service attacks are no longer 
   427   necessary.
   428 
   429 
   430 
   431 Examples:
   432 @code
   433 #include <sys/socket.h>
   434 #include <netinet/in.h>
   435 #include <unistd.h>
   436 void listen_example()
   437 {
   438    int sock_fd;
   439    int newsock_fd;
   440    struct sockaddr_in addr;
   441    struct sockaddr_in ss;
   442    struct sockaddr_in new_socket;
   443    unsigned int len;
   444    unsigned int addr_len;
   445    
   446    sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   447        
   448    addr.sin_family = AF_INET;
   449    addr.sin_addr.s_addr = htonl(INADDR_ANY);
   450    addr.sin_port = htons(5000);
   451    bind(sock_fd,(struct sockaddr*)&addr;,sizeof(addr));
   452    listen(sock_fd,1);
   453    close(sock_fd);
   454 }
   455 
   456 @endcode
   457 @see accept()
   458 @see connect()
   459 @see socket()
   460 
   461 
   462  
   463 
   464 @publishedAll
   465 @externallyDefinedApi
   466 */
   467 
   468 /** @fn  recv(int fd, void *buf, size_t cnt, int flags)
   469 @param fd
   470 @param buf
   471 @param cnt
   472 @param flags
   473 
   474 Note: This description also covers the following functions -
   475  recvfrom()  recvmsg() 
   476 
   477 @return   These calls return the number of bytes received, or -1
   478 if an error occurred.
   479 
   480 @code
   481  MSG_OOB                process out-of-band data
   482 @endcode
   483 
   484   The recvfrom and recvmsg system calls
   485 are used to receive messages from a socket,
   486 and may be used to receive data on a socket whether or not
   487 it is connection-oriented.
   488 
   489  If from is not a null pointer
   490 and the socket is not connection-oriented,
   491 the source address of the message is filled in.
   492 The fromlen argument
   493 is a value-result argument, initialized to the size of
   494 the buffer associated with from, and modified on return to indicate the actual size of the
   495 address stored there.
   496 
   497  The recv function is normally used only on a connected socket (see connect )
   498 and is identical to recvfrom with a
   499 null pointer passed as its from argument.
   500 As it is redundant, it may not be supported in future releases.
   501 
   502  All three routines return the length of the message on successful
   503 completion.
   504 If a message is too long to fit in the supplied buffer,
   505 excess bytes may be discarded depending on the type of socket
   506 the message is received from (see socket )
   507 
   508  If no messages are available at the socket, the
   509 receive call waits for a message to arrive, unless
   510 the socket is nonblocking (see fcntl )
   511 in which case the value
   512 -1 is returned and the external variable errno set to EAGAIN. The receive calls normally return any data available,
   513 up to the requested amount,
   514 rather than waiting for receipt of the full amount requested;
   515 this behavior is affected by the socket-level options SO_RCVLOWAT and SO_RCVTIMEO described in getsockopt .
   516 
   517  The select system call may be used to determine when more data arrive.
   518 
   519  The flags argument to a recv function is formed by or Ap ing one or more of the values: MSG_OOB                process out-of-band data MSG_PEEK                peek at incoming message MSG_WAITALL                wait for full request or error MSG_DONTWAIT                do not block 
   520 
   521  The MSG_OOB flag requests receipt of out-of-band data
   522 that would not be received in the normal data stream.
   523 Some protocols place expedited data at the head of the normal
   524 data queue, and thus this flag cannot be used with such protocols.
   525 The MSG_PEEK flag causes the receive operation to return data
   526 from the beginning of the receive queue without removing that
   527 data from the queue.
   528 Thus, a subsequent receive call will return the same data.
   529 The MSG_WAITALL flag requests that the operation block until
   530 the full request is satisfied.
   531 The MSG_DONTWAIT flag requests the call to return when it would block otherwise.
   532 If no data is available, errno is set to EAGAIN.
   533 
   534 The flags MSG_OOB, MSG_PEEK, MSG_WAITALL and MSG_DONTWAIT are not supported for 
   535 local sockets(AF_LOCAL, AF_LINUX etc..).
   536 
   537  The recvmsg system call uses a msghdr structure to minimize the number of directly supplied arguments.
   538 This structure has the following form, as defined in \#include \<sys/socket.h\>
   539 @code
   540  struct msghdr {
   541 caddr_tmsg_name;/* optional address */
   542 u_intmsg_namelen;/* size of address */
   543 structiovec *msg_iov;/* scatter/gather array */
   544 u_intmsg_iovlen;/* # elements in msg_iov */
   545 caddr_tmsg_control;/* ancillary data, see below */
   546 u_intmsg_controllen; /* ancillary data buffer len */
   547 intmsg_flags;/* flags on received message */
   548 };
   549 @endcode
   550 
   551  Here msg_name and msg_namelen specify the destination address if the socket is unconnected; msg_name may be given as a null pointer if no names are desired or required.
   552 The msg_iov and msg_iovlen arguments
   553 describe scatter gather locations, as discussed in read .
   554 The msg_control argument,
   555 which has length msg_controllen, points to a buffer for other protocol control related messages
   556 or other miscellaneous ancillary data.
   557 The messages are of the form: 
   558 @code
   559 struct cmsghdr {
   560 u_intcmsg_len;/* data byte count, including hdr */
   561 intcmsg_level;/* originating protocol */
   562 intcmsg_type;/* protocol-specific type */
   563 /* followed by
   564 u_charcmsg_data[]; */
   565 };
   566 @endcode
   567 
   568  As an example, one could use this to learn of changes in the data-stream
   569 in XNS/SPP, or in ISO, to obtain user-connection-request data by requesting
   570 a recvmsg with no data buffer provided immediately after an accept system call.
   571 
   572  Open file descriptors are now passed as ancillary data for AF_UNIX domain sockets, with cmsg_level set to SOL_SOCKET and cmsg_type set to SCM_RIGHTS.
   573 
   574  Process credentials can also be passed as ancillary data for AF_UNIX domain sockets using a cmsg_type of SCM_CREDS. In this case, cmsg_data should be a structure of type cmsgcred, which is defined in \#include \<sys/socket.h\> as follows:
   575 @code
   576  struct cmsgcred {
   577 pid_tcmcred_pid;/* PID of sending process */
   578 uid_tcmcred_uid;/* real UID of sending process */
   579 uid_tcmcred_euid;/* effective UID of sending process */
   580 gid_tcmcred_gid;/* real GID of sending process */
   581 shortcmcred_ngroups;/* number or groups */
   582 gid_tcmcred_groups[CMGROUP_MAX];/* groups */
   583 };
   584 @endcode
   585 
   586  The kernel will fill in the credential information of the sending process
   587 and deliver it to the receiver.
   588 
   589  The msg_flags field is set on return according to the message received. MSG_EOR indicates end-of-record; the data returned completed a record 
   590   (generally used with sockets of type SOCK_SEQPACKET). MSG_TRUNC indicates that the trailing portion of a datagram was discarded 
   591   because the datagram was larger than the buffer supplied. MSG_CTRUNC indicates that some control data were discarded due to 
   592   lack of space in the buffer for ancillary data. MSG_OOB is returned to indicate that expedited or out-of-band data 
   593   were received.
   594 
   595 Examples:
   596 @code
   597 #include <sys/socket.h>
   598 #include <netinet/in.h>
   599 #include <unistd.h>
   600 void Recv()
   601 {
   602    struct sockaddr_in serv_addr;
   603    int sock_fd;
   604    char line[10];
   605    int size = 10;
   606    serv_addr.sin_family = AF_INET;
   607    serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   608    serv_addr.sin_port = htons(5000);
   609    sock_fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
   610    connect(sock_fd,(struct sockaddr*)&serv;_addr,sizeof(serv_addr));
   611    recv(sock_fd, line, size, 0);
   612    close(sock_fd);
   613 }
   614 
   615 @endcode
   616 @code
   617 #include <sys/socket.h>
   618 #include <netinet/in.h>
   619 #include <unistd.h>
   620 void Sendto()
   621 {
   622    struct sockaddr_in sender_addr;
   623    int sock_fd;
   624    char line[15] = "Hello World!";
   625    unsigned int size = sizeof(sender_addr);
   626    sock_fd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
   627    sender_addr.sin_family = AF_INET;
   628    sender_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   629    sender_addr.sin_port = htons(5000);
   630    recvfrom(sock_fd,line,13,0,(struct sockaddr*)&sender;_addr,&size;);
   631    close(sock_fd);
   632 }
   633 
   634 @endcode
   635 @code
   636 #include <sys/socket.h>
   637 #include <netinet/in.h>
   638 #include <unistd.h>
   639 void SendMsgRecvMsg()
   640 {
   641    int sock_fd;
   642    unsigned int sender_len;
   643    struct msghdr msg;
   644    struct iovec iov;
   645    struct sockaddr_in receiver_addr,sender_addr;
   646    char line[10];
   647    sock_fd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
   648    receiver_addr.sin_family = AF_INET;
   649    receiver_addr.sin_addr.s_addr = htonl(INADDR_ANY);
   650    receiver_addr.sin_port = htons(5000);
   651    bind(sock_fd,(struct sockaddr*)&receiver;_addr,sizeof(receiver_addr));
   652    sender_len = sizeof(sender_addr);
   653    msg.msg_name = &sender;_addr;
   654    msg.msg_namelen = sender_len;
   655    msg.msg_iov = &iov;
   656    msg.msg_iovlen = 1;
   657    msg.msg_iov->iov_base = line;
   658    msg.msg_iov->iov_len = 10;
   659    msg.msg_control = 0;
   660    msg.msg_controllen = 0;
   661    msg.msg_flags = 0;
   662    recvmsg(sock_fd,&msg;,0);
   663    close(sock_fd);
   664 }
   665 
   666 @endcode
   667 @see fcntl()
   668 @see getsockopt()
   669 @see read()
   670 @see select()
   671 @see socket()
   672 
   673 
   674 
   675 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
   676 
   677 @publishedAll
   678 @externallyDefinedApi
   679 */
   680 
   681 
   682 /** @fn  recvfrom(int s, void *  buf, size_t len, int flags, struct sockaddr *  from, socklen_t *  fromlen)
   683 @param s
   684 @param buf
   685 @param len
   686 @param flags
   687 @param from
   688 @param fromlen
   689 
   690 Refer to recv() for the documentation
   691 
   692 @see fcntl()
   693 @see getsockopt()
   694 @see read()
   695 @see select()
   696 @see socket()
   697 
   698 
   699 
   700 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
   701 
   702 @publishedAll
   703 @externallyDefinedApi
   704 */
   705 
   706 
   707 /** @fn  recvmsg(int fd, struct msghdr *message, int flags)
   708 @param fd
   709 @param message
   710 @param flags
   711 
   712 Refer to recv() for the documentation
   713 
   714 @see fcntl()
   715 @see getsockopt()
   716 @see read()
   717 @see select()
   718 @see socket()
   719 
   720 
   721 
   722 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
   723 
   724 @publishedAll
   725 @externallyDefinedApi
   726 */
   727 
   728 /** @fn  send(int fd, const void *buf, size_t cnt, int flags)
   729 @param fd
   730 @param buf
   731 @param cnt
   732 @param flags
   733 
   734 Note: This description also covers the following functions -
   735  sendto()  sendmsg() 
   736 
   737   The send function,
   738 and sendto and sendmsg system calls
   739 are used to transmit a message to another socket.
   740 The send function
   741 may be used only when the socket is in a connected state, while sendto and sendmsg may be used at any time.
   742 
   743  The address of the target is given by to with tolen specifying its size.
   744 The length of the message is given by len. If the message is too long to pass atomically through the
   745 underlying protocol, the error EMSGSIZE is returned, and
   746 the message is not transmitted.
   747 
   748  No indication of failure to deliver is implicit in a send. Locally detected errors are indicated by a return value of -1.
   749 
   750  If no messages space is available at the socket to hold
   751 the message to be transmitted, then send normally blocks, unless the socket has been placed in
   752 non-blocking I/O mode.
   753 The select system call may be used to determine when it is possible to
   754 send more data.
   755 
   756  The flags argument may include one or more of the following: 
   757 @code
   758 #defineMSG_OOB0x00001 //process out-of-band data 
   759 #defineMSG_PEEK0x00002 // peek at incoming message 
   760 #defineMSG_DONTROUTE0x00004 // bypass routing, use direct interface 
   761 #define MSG_EOR0x00008 // data completes record 
   762 #defineMSG_EOF0x00100 // data completes transaction
   763 @endcode
   764 
   765  The flag MSG_OOB is used to send "out-of-band"
   766 data on sockets that support this notion (e.g. SOCK_STREAM); the underlying protocol must also support "out-of-band"
   767 data. MSG_EOR is used to indicate a record mark for protocols which support the
   768 concept. MSG_EOF requests that the sender side of a socket be shut down, and that an
   769 appropriate indication be sent at the end of the specified data;
   770 this flag is only implemented for SOCK_STREAM sockets in the PF_INET protocol family, and is used to implement Transaction TCP MSG_DONTROUTE is usually used only by diagnostic or routing programs.
   771 
   772  See recv for a description of the msghdr structure.
   773 
   774 Examples:
   775 @code
   776 #include <sys/socket.h>
   777 #include <netinet/in.h>
   778 #include <unistd.h>
   779 void Recv()
   780 {
   781    struct sockaddr_in serv_addr;
   782    int sock_fd;
   783    char line[15] = "Hello world!";
   784    int size = 13;
   785    serv_addr.sin_family = AF_INET;
   786    serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   787    serv_addr.sin_port = htons(5000);
   788    sock_fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
   789    connect(sock_fd,(struct sockaddr*)&serv;_addr,sizeof(serv_addr));
   790    send(sock_fd, line, size, 0);
   791    close(sock_fd);
   792 }
   793 
   794 @endcode
   795 @code
   796 #include <sys/socket.h>
   797 #include <netinet/in.h>
   798 #include <unistd.h>
   799 void Sendto()
   800 {
   801    sockaddr_in receiver_addr;
   802    int sock_fd;
   803    char line[15] = "Hello World!";
   804    sock_fd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
   805    receiver_addr.sin_family = AF_INET;
   806    receiver_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   807    receiver_addr.sin_port = htons(5000);
   808    sendto(sock_fd, line, 13, 0,(struct sockaddr*)&receiver;_addr,sizeof(receiver_addr));
   809    close(sock_fd);
   810 }
   811 
   812 @endcode
   813 @code
   814 #include <sys/socket.h>
   815 #include <netinet/in.h>
   816 #include <unistd.h>
   817 void sendmsg()
   818 {
   819    struct sockaddr_in receiver_addr;
   820    int sock_fd;
   821    char line[15] = "Hello World!";
   822    struct msghdr msg;
   823    struct iovec iov;
   824    sock_fd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
   825     
   826    receiver_addr.sin_family = AF_INET;
   827    receiver_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   828    receiver_addr.sin_port = htons(5000);
   829    msg.msg_name = &receiver;_addr;
   830    msg.msg_namelen = sizeof(receiver_addr);
   831    msg.msg_iov = &iov;
   832    msg.msg_iovlen = 1;
   833    msg.msg_iov->iov_base = line;
   834    msg.msg_iov->iov_len = 13;
   835    msg.msg_control = 0;
   836    msg.msg_controllen = 0;
   837    msg.msg_flags = 0;
   838    sendmsg(sock_fd,&msg;,0);
   839    close(sock_fd);
   840 }
   841 
   842 @endcode
   843 @return   This function call returns the number of characters sent; otherwise the
   844 value -1 is returned and the global variable errno is set to indicate the
   845 error.
   846 
   847 @see fcntl()
   848 @see getsockopt()
   849 @see recv()
   850 @see select()
   851 @see socket()
   852 @see write()
   853 
   854 
   855 Bugs:
   856 
   857  Because sendmsg does not necessarily block until the data has been transferred, it
   858 is possible to transfer an open file descriptor across an AF_UNIX domain socket
   859 (see recv then close it before it has actually been sent, the result being that the receiver
   860 gets a closed file descriptor.
   861 It is left to the application to
   862 implement an acknowledgment mechanism to prevent this from happening. 
   863 
   864 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
   865 
   866 @publishedAll
   867 @externallyDefinedApi
   868 */
   869 
   870 /** @fn  sendto(int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)
   871 @param s
   872 @param msg
   873 @param len
   874 @param flags
   875 @param to
   876 @param tolen
   877 
   878 Refer to  send() for the documentation
   879 
   880 @see fcntl()
   881 @see getsockopt()
   882 @see recv()
   883 @see select()
   884 @see socket()
   885 @see write()
   886 
   887 
   888 
   889 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
   890 
   891 @publishedAll
   892 @externallyDefinedApi
   893 */
   894 
   895 /** @fn  sendmsg(int fd, const struct msghdr *message, int flags)
   896 @param fd
   897 @param message
   898 @param flags
   899 
   900 Refer to  send() for the documentation
   901 
   902 @see fcntl()
   903 @see getsockopt()
   904 @see recv()
   905 @see select()
   906 @see socket()
   907 @see write()
   908 
   909 
   910 
   911 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
   912 
   913 @publishedAll
   914 @externallyDefinedApi
   915 */
   916 
   917 
   918 /** @fn  setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
   919 @param s
   920 @param level
   921 @param optname
   922 @param optval
   923 @param optlen
   924 
   925 Refer to  getsockopt() for the documentation
   926 
   927 @see ioctl()
   928 @see socket()
   929 
   930 
   931 Note:For multicast to work on Symbian OS the connection for the interface needs to be started first.
   932 On most of the desktop Operating Systems,the network interface is always running, so things like setsockopt() will always pass.
   933 But on Symbian, the interface is not always running (in order to save battery and/or data charges) so some options in setsockopt() will not work until the connection is started.
   934 
   935  
   936 
   937 @publishedAll
   938 @externallyDefinedApi
   939 */
   940 
   941 
   942 /** @fn  shutdown(int fd, int how)
   943 @param fd
   944 @param how
   945 @return   The shutdown() function returns the value 0 if successful; otherwise the
   946 value -1 is returned and the global variable errno is set to indicate the
   947 error.
   948 
   949 @code
   950  SHUT_RD further receives will be disallowed.
   951  SHUT_WR further sends will be disallowed.
   952  SHUT_RDWR
   953   further sends and receives will be disallowed.
   954 
   955 @endcode
   956   The shutdown system call causes all or part of a full-duplex connection on
   957 the socket associated with the file descriptor sockfd to be shut down.
   958 The how argument specifies the type of shutdown.
   959 Possible values are: SHUT_RD further receives will be disallowed. SHUT_WR further sends will be disallowed. SHUT_RDWR  further sends and receives will be disallowed.
   960 
   961 Examples:
   962 @code
   963 #include <sys/socket.h>
   964 #include <netinet/in.h>
   965 #include <unistd.h>
   966 TInt shutdown_example()
   967 {
   968    int sock_fd;
   969    sockaddr_in addr,ss;
   970    unsigned int len;   
   971    
   972    sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   973        
   974    addr.sin_family = AF_INET;
   975    addr.sin_addr.s_addr = htonl(INADDR_ANY);
   976    addr.sin_port = htons(5000);
   977    bind(sock_fd,(sockaddr*)&addr;,sizeof(addr));
   978    shutdown(sock_fd, SHUT_RD)
   979    close(sock_fd);
   980 }
   981 
   982 @endcode
   983 @see connect()
   984 @see socket()
   985 
   986 
   987  
   988 
   989 @publishedAll
   990 @externallyDefinedApi
   991 */
   992 
   993 /** @fn  sockatmark(int s)
   994 @param s
   995 @return   Upon successful completion, the sockatmark function returns the value 1 if the read pointer is pointing at
   996 the OOB mark, 0 if it is not.Otherwise the value -1 is returned
   997 and the global variable errno is set to indicate the error.
   998 
   999   To find out if the read pointer is currently pointing at
  1000 the mark in the data stream, the sockatmark function is provided.
  1001 If sockatmark returns 1, the next read will return data
  1002 after the mark.
  1003 Otherwise (assuming out of band data has arrived),
  1004 the next read will provide data sent by the client prior
  1005 to transmission of the out of band signal.
  1006 The routine used
  1007 in the remote login process to flush output on receipt of an
  1008 interrupt or quit signal is shown below.
  1009 It reads the normal data up to the mark (to discard it),
  1010 then reads the out-of-band byte. 
  1011 @code
  1012 #include <sys/socket.h>
  1013 oob()
  1014 {
  1015 int out = FWRITE, mark;
  1016 char waste[BUFSIZ];
  1017 /* flush local terminal output */
  1018 ioctl(1, TIOCFLUSH, (char *)&out;);
  1019 for (;;) {
  1020 if ((mark = sockatmark(rem)) < 0) {
  1021 perror("sockatmark");
  1022 break;
  1023 }
  1024 if (mark)
  1025 break;
  1026 (void) read(rem, waste, sizeof (waste));
  1027 }
  1028 if (recv(rem, &mark;, 1, MSG_OOB) < 0) {
  1029 perror("recv");
  1030 ...
  1031 }
  1032 ...
  1033 }
  1034 @endcode
  1035 
  1036 Examples:
  1037 @code
  1038 #include <sys/socket.h>
  1039 #include <netinet/in.h>
  1040 #include <unistd.h>
  1041 void SockAtMark()
  1042 {
  1043    int sockfd;
  1044    sockaddr_in selfAddr;
  1045    sockfd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  1046        
  1047    selfAddr.sin_family = AF_INET;
  1048    selfAddr.sin_addr.s_addr = INADDR_ANY;
  1049    selfAddr.sin_port = htons(5000);
  1050    bind(sockfd,(struct sockaddr*)&selfAddr;, sizeof(selfAddr));
  1051    sockatmark(sockfd);
  1052    close(sockfd);
  1053 }
  1054 
  1055 @endcode
  1056 @see recv()
  1057 @see send()
  1058 @see ioctl()
  1059 
  1060 
  1061  
  1062 
  1063 @publishedAll
  1064 @externallyDefinedApi
  1065 */
  1066 
  1067 
  1068 /** @fn  socket(int family, int style, int protocol)
  1069 @param family
  1070 @param style
  1071 @param protocol
  1072 @return   The socket() function returns valid socket descriptor if successful; otherwise the
  1073 value -1 is returned and the global variable errno is set to indicate the
  1074 error.
  1075 
  1076   The socket system call
  1077 creates an endpoint for communication and returns a descriptor.
  1078 
  1079  The family argument specifies a communications domain within which communication 
  1080   will take place; this selects the protocol family which should be used. These 
  1081   families are defined in the include file \#include \<sys/socket.h\> The currently understood formats 
  1082   are:
  1083 
  1084  PF_LOCALHost-internal protocols, formerly called PF_UNIX,
  1085 PF_INETInternet version 4 protocols,
  1086 
  1087  The socket has the indicated style, which specifies the semantics of communication.
  1088 Currently
  1089 defined types are:
  1090 
  1091 @code
  1092 
  1093 SOCK_STREAMStream socket,
  1094 SOCK_DGRAMDatagram socket,
  1095 SOCK_SEQPACKETSequenced packet stream
  1096 
  1097 @endcode
  1098 
  1099  A SOCK_STREAM type provides sequenced, reliable,
  1100 two-way connection based byte streams.
  1101 An out-of-band data transmission mechanism may be supported.
  1102 A SOCK_DGRAM socket supports
  1103 datagrams (connectionless, unreliable messages of
  1104 a fixed (typically small) maximum length).
  1105 A SOCK_SEQPACKET socket may provide a sequenced, reliable,
  1106 two-way connection-based data transmission path for datagrams
  1107 of fixed maximum length; a consumer may be required to read
  1108 an entire packet with each read system call.
  1109 This facility is protocol specific, and presently unimplemented.
  1110 
  1111  The protocol argument
  1112 specifies a particular protocol to be used with the socket.
  1113 Normally only a single protocol exists to support a particular
  1114 socket type within a given protocol family.
  1115 However, it is possible
  1116 that many protocols may exist, in which case a particular protocol
  1117 must be specified in this manner.
  1118 The protocol number to use is
  1119 particular to the "communication domain"
  1120 in which communication
  1121 is to take place.
  1122 
  1123  Sockets of type SOCK_STREAM are full-duplex byte streams, similar
  1124 to pipes.
  1125 A stream socket must be in a connected state before any data may be sent or received
  1126 on it.
  1127 A connection to another socket is created with a connect system call.
  1128 Once connected, data may be transferred using read and write calls or some variant of the send and recv functions.
  1129 (Some protocol families, such as the Internet family,
  1130 support the notion of an "implied connect,"
  1131 which permits data to be sent piggybacked onto a connect operation by
  1132 using the sendto system call.)
  1133 When a session has been completed a close may be performed.
  1134 Out-of-band data may also be transmitted as described in send and received as described in recv
  1135 
  1136  The communications protocols used to implement a SOCK_STREAM insure that data
  1137 is not lost or duplicated.
  1138 If a piece of data for which the
  1139 peer protocol has buffer space cannot be successfully transmitted
  1140 within a reasonable length of time, then
  1141 the connection is considered broken and calls
  1142 will indicate an error with
  1143 -1 returns and with ETIMEDOUT as the specific code
  1144 in the global variable errno. The protocols optionally keep sockets "warm"
  1145 by forcing transmissions
  1146 roughly every minute in the absence of other activity.
  1147 An error is then indicated if no response can be
  1148 elicited on an otherwise
  1149 idle connection for an extended period (e.g. 5 minutes).
  1150 
  1151  SOCK_SEQPACKET sockets employ the same system calls as SOCK_STREAM sockets. The only difference is that read calls will return only the amount of data 
  1152   requested and any remaining in the arriving packet will be discarded.
  1153 
  1154  SOCK_DGRAM sockets allow sending of datagrams to correspondents named 
  1155   in send calls. Datagrams are generally received 
  1156   with recvfrom which returns the next datagram with 
  1157   its return address.
  1158 
  1159 Examples:
  1160 @code
  1161 #include <sys/socket.h>
  1162 #include <unistd.h>
  1163 #include <stdio.h>
  1164 #inlcude <netinet/in.h>
  1165 void SocketExample()
  1166 {
  1167     int sock_fd;
  1168     sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  1169     close(sock_fd);
  1170 }
  1171 
  1172 @endcode
  1173 @see accept()
  1174 @see bind()
  1175 @see connect()
  1176 @see getpeername()
  1177 @see getsockname()
  1178 @see getsockopt()
  1179 @see ioctl()
  1180 @see listen()
  1181 @see read()
  1182 @see recv()
  1183 @see select()
  1184 @see send()
  1185 @see shutdown()
  1186 @see write()
  1187 
  1188 
  1189 
  1190 @capability Deferred @ref RSocket::Open(RSocketServ &,TUint,TUint,TUint)
  1191 
  1192 @publishedAll
  1193 @externallyDefinedApi
  1194 */
  1195 
  1196 
  1197 /** @typedef typedef	__sa_family_t	sa_family_t
  1198 
  1199 Address family type
  1200 
  1201 @publishedAll
  1202 @externallyDefinedApi
  1203 */
  1204 
  1205 /** @typedef typedef	__socklen_t	socklen_t
  1206 
  1207 Socket address length type.
  1208 
  1209 @publishedAll
  1210 @externallyDefinedApi
  1211 */
  1212 
  1213 /** @struct sockaddr
  1214 
  1215 Structure used by kernel to store most addresses.
  1216 
  1217 @publishedAll
  1218 @externallyDefinedApi
  1219 */
  1220 
  1221 /** @var sockaddr::sa_len
  1222 total length 
  1223 */
  1224 
  1225 /** @var sockaddr::sa_family
  1226 address family 
  1227 */
  1228 
  1229 /** @var sockaddr::sa_data
  1230 actually longer; address value
  1231 */
  1232 
  1233 /** @struct cmsghdr
  1234 
  1235 Header for ancillary data objects in msg_control buffer.
  1236 Used for additional information with/about a datagram not expressible by flags.  
  1237 The format is a sequence of message elements headed by cmsghdr structures.
  1238 
  1239 @publishedAll
  1240 @externallyDefinedApi
  1241 */
  1242 
  1243 /** @var cmsghdr::cmsg_len
  1244 data byte count, including hdr
  1245 */
  1246 
  1247 /** @var cmsghdr::cmsg_level
  1248 originating protocol
  1249 */
  1250 
  1251 /** @var cmsghdr::cmsg_type
  1252 protocol-specific type
  1253 */
  1254 
  1255 
  1256 /** @struct msghdr
  1257 
  1258 Message header for recvmsg and sendmsg calls.
  1259 Used value-result for recvmsg, value only for sendmsg.
  1260 
  1261 @publishedAll
  1262 @externallyDefinedApi
  1263 */
  1264 
  1265 /** @var msghdr::msg_name
  1266 optional address
  1267 */
  1268 
  1269 /** @var msghdr::msg_namelen
  1270 size of address 
  1271 */
  1272 
  1273 /** @var msghdr::msg_iov
  1274 scatter or gather array
  1275 */
  1276 
  1277 /** @var msghdr::msg_iovlen
  1278 x elements in msg_iov 
  1279 */
  1280 
  1281 /** @var msghdr::msg_control
  1282 ancillary data, see below
  1283 */
  1284 
  1285 /** @var msghdr::msg_controllen
  1286 ancillary data buffer len 
  1287 */
  1288 
  1289 /** @var msghdr::msg_flags
  1290 flags on received message
  1291 */
  1292 
  1293 /** @def CMSG_DATA(cmsg)
  1294 
  1295 given pointer to struct cmsghdr, return pointer to data
  1296 	
  1297 @publishedAll
  1298 @externallyDefinedApi
  1299 */
  1300 
  1301 /** @def CMSG_NXTHDR(mhdr, cmsg)
  1302 
  1303 given pointer to struct cmsghdr, return pointer to next cmsghdr
  1304 
  1305 @publishedAll
  1306 @externallyDefinedApi
  1307 */
  1308 
  1309 
  1310 /** @def CMSG_FIRSTHDR(mhdr)
  1311 
  1312 RFC 2292 requires to check msg_controllen, in case that the kernel returns an empty list for some reasons.
  1313 
  1314 @publishedAll
  1315 @externallyDefinedApi
  1316 */
  1317 
  1318 /** @struct linger
  1319 
  1320 Structure used for manipulating linger option.
  1321 
  1322 @publishedAll
  1323 @externallyDefinedApi
  1324 */
  1325 
  1326 /** @var linger::l_onoff
  1327 option on or off
  1328 */
  1329 
  1330 /** @var linger::l_linger
  1331 linger time 
  1332 */
  1333 
  1334 
  1335 /** @def AF_UNIX
  1336 
  1337 local to host (pipes, portals) 
  1338 
  1339 @publishedAll
  1340 @externallyDefinedApi
  1341 */
  1342 	
  1343 /** @def AF_INET	
  1344 
  1345 internetwork: UDP, TCP, etc.
  1346 
  1347 @publishedAll
  1348 @externallyDefinedApi
  1349 */
  1350 
  1351 /** @def AF_UNSPEC
  1352 
  1353 Address family. Unspecified.
  1354 
  1355 @publishedAll
  1356 @externallyDefinedApi
  1357 */
  1358 
  1359 /** @def SHUT_RD	
  1360 
  1361 shut down the reading side
  1362 
  1363 @publishedAll
  1364 @externallyDefinedApi
  1365 */
  1366 
  1367 /** @def SHUT_WR
  1368 
  1369 shut down the writing side 
  1370 
  1371 @publishedAll
  1372 @externallyDefinedApi
  1373 */
  1374 
  1375 /** @def SHUT_RDWR
  1376 
  1377 shut down both sides
  1378 
  1379 @publishedAll
  1380 @externallyDefinedApi
  1381 */
  1382 
  1383 
  1384 /** @def MSG_OOB	
  1385 
  1386 process out-of-band data
  1387 
  1388 @publishedAll
  1389 @externallyDefinedApi
  1390 */
  1391 
  1392 /** @def MSG_PEEK
  1393 
  1394 peek at incoming message
  1395 
  1396 @publishedAll
  1397 @externallyDefinedApi
  1398 */
  1399 
  1400 /** @def MSG_DONTROUTE
  1401 
  1402 send without using routing tables 
  1403 
  1404 @publishedAll
  1405 @externallyDefinedApi
  1406 */
  1407 
  1408 /** @def MSG_EOR
  1409 
  1410 data completes record
  1411 
  1412 @publishedAll
  1413 @externallyDefinedApi
  1414 */
  1415 
  1416 /** @def MSG_TRUNC
  1417 
  1418 data discarded before delivery 
  1419 
  1420 @publishedAll
  1421 @externallyDefinedApi
  1422 */
  1423 
  1424 /** @def MSG_CTRUNC
  1425 
  1426 control data lost before delivery 
  1427 
  1428 @publishedAll
  1429 @externallyDefinedApi
  1430 */
  1431 
  1432 /** @def MSG_WAITALL
  1433 
  1434 wait for full request or error
  1435 
  1436 @publishedAll
  1437 @externallyDefinedApi
  1438 */
  1439 
  1440 /** @def SO_ACCEPTCONN	
  1441 
  1442 socket has had listen() 
  1443 
  1444 @publishedAll
  1445 @externallyDefinedApi
  1446 */
  1447 
  1448 /** @def SO_BROADCAST
  1449 
  1450 permit sending of broadcast msgs
  1451 
  1452 @publishedAll
  1453 @externallyDefinedApi
  1454 */
  1455 
  1456 
  1457 /** @def SO_DEBUG
  1458 
  1459 turn on debugging info recording KSODebug 
  1460 
  1461 @publishedAll
  1462 @externallyDefinedApi
  1463 */
  1464 
  1465 /** @def SO_DONTROUTE
  1466 
  1467 just use interface addresses
  1468 
  1469 @publishedAll
  1470 @externallyDefinedApi
  1471 */
  1472 
  1473 /** @def SO_ERROR
  1474 
  1475 get error status and clear
  1476 
  1477 @publishedAll
  1478 @externallyDefinedApi
  1479 */
  1480 
  1481 /** @def SO_KEEPALIVE
  1482 
  1483 keep connections alive KSoTcpKeepAlive 
  1484 
  1485 @publishedAll
  1486 @externallyDefinedApi
  1487 */
  1488 
  1489 /** @def SO_LINGER
  1490 
  1491 linger on close if data present
  1492 
  1493 @publishedAll
  1494 @externallyDefinedApi
  1495 */
  1496 
  1497 /** @def SO_OOBINLINE
  1498 
  1499 leave received OOB data in line KSoTcpOobInline
  1500 
  1501 @publishedAll
  1502 @externallyDefinedApi
  1503 */
  1504 
  1505 
  1506 /** @def SO_RCVBUF
  1507 
  1508 receive buffer size KSORecvBuf 
  1509 
  1510 @publishedAll
  1511 @externallyDefinedApi
  1512 */
  1513 
  1514 /** @def SO_RCVLOWAT
  1515 
  1516 receive low-water mark
  1517 
  1518 @publishedAll
  1519 @externallyDefinedApi
  1520 */
  1521 
  1522 /** @def SO_RCVTIMEO
  1523 
  1524 receive timeout
  1525 
  1526 @publishedAll
  1527 @externallyDefinedApi
  1528 */
  1529 
  1530 /** @def SO_REUSEADDR
  1531 
  1532 Allow a socket to be bound to an local address that is already in use. 
  1533 
  1534 @publishedAll
  1535 @externallyDefinedApi
  1536 */
  1537 
  1538 
  1539 /** @def SO_SNDBUF
  1540 
  1541 send buffer size KSOSendBuf 
  1542 
  1543 @publishedAll
  1544 @externallyDefinedApi
  1545 */
  1546 
  1547 /** @def SO_SNDLOWAT
  1548 
  1549 send low-water mark
  1550 
  1551 @publishedAll
  1552 @externallyDefinedApi
  1553 */
  1554 
  1555 /** @def SO_SNDTIMEO
  1556 
  1557 send timeout
  1558 
  1559 @publishedAll
  1560 @externallyDefinedApi
  1561 */
  1562 
  1563 
  1564 /** @def SO_TYPE	
  1565 
  1566 get socket type 
  1567 
  1568 @publishedAll
  1569 @externallyDefinedApi
  1570 */
  1571 
  1572 /** @def SOCK_DGRAM
  1573 
  1574 datagram socket
  1575 
  1576 @publishedAll
  1577 @externallyDefinedApi
  1578 */
  1579 
  1580 /** @def SOCK_STREAM
  1581 
  1582 stream socket
  1583 
  1584 @publishedAll
  1585 @externallyDefinedApi
  1586 */
  1587 
  1588 /** @def SOCK_SEQPACKET
  1589 
  1590 sequenced packet stream 
  1591 
  1592 @publishedAll
  1593 @externallyDefinedApi
  1594 */
  1595 
  1596 
  1597 /** @def SOL_SOCKET
  1598 
  1599 options for socket level KSOLSocket
  1600 
  1601 @publishedAll
  1602 @externallyDefinedApi
  1603 */
  1604 
  1605 
  1606 /** @def SOCK_RAW
  1607 
  1608 raw-protocol interface
  1609 
  1610 @publishedAll
  1611 @released
  1612 */
  1613 
  1614 
  1615 
  1616 
  1617 
  1618