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