XSocket API  2.0
XIA Socket Library
Functions
Xsetsockopt.c File Reference

Xsetsockopt(),X getsockopt() - get and set options on sockets. More...

#include "Xsocket.h"

Functions

int Xsetsockopt (int sockfd, int optname, const void *optval, socklen_t optlen)
 Xsocket implemention of the standard setsockopt function. More...
 
int Xgetsockopt (int sockfd, int optname, void *optval, socklen_t *optlen)
 Xsocket implemention of the standard getsockopt function. More...
 

Function Documentation

int Xgetsockopt ( int  sockfd,
int  optname,
void *  optval,
socklen_t *  optlen 
)

Xgetsockopt is used to retrieve the settings of the underlying Xsocket in the Click layer. It does not access the settings of the actual socket passed in which is used by the API to communicate with Click.

Supported Options:
XOPT_HLIM: retrieves the 'hop limit' element of the XIA header as an integer value
XOPT_NEXT_PROTO: gets the next proto field in the XIA header
SO_TYPE: returns the type of socket (SOCK_STREAM, etc...)
XOPT_ERROR_PEEK: returns the socket's error code without resetting it
SO_ACCEPTCONN: indicates whether the socket is in listen mode
SO_ERROR: return the socket's error cod. Useful for non-blocking connect calls
SO_DEBUG: return the value of the socket's debug flag
SO_DOMAIN: always returns AF_XIA
SO_PROTOCOL: returns the socket's protocol flags. Currently always 0.

Parameters
sockfdThe control socket
optnameThe socket option to set (currently must be IP_TTL)
optvalA pointer to the value to retrieve
optlenA pointer to the length of optval. On input this should be set to the length of the data passed in. If optlen is not large enough, Xgetsockopt will set it to the size needed and return with errno set to EINVAL. If larger than needed, Xgetsockopt will set it to the actual length of the returned data.
Returns
0 on success
-1 on error with errno set
errno values:
EBADF: The socket descriptor is invalid
EINVAL: Either optval is null, or optlen is invalid, or optval is out of range
ENOPROTOOPT: the specified optname is not recognized
int Xsetsockopt ( int  sockfd,
int  optname,
const void *  optval,
socklen_t  optlen 
)

Xsetsockopt is used to set options on the underlying Xsocket in the Click layer. It does not affect the actual socket passed in which used by the API to communicate with Click.

Supported Options:
XOPT_HLIM: sets the 'hop limit' (hlim) element of the XIA header to the specified integer value. (Default is 250)
XOPT_NEXT_PROTO: sets the next proto field in the XIA header
XOPT_BLOCK: alternate method of setting the blocking flag Xfcntl() or Xsocket() is preferred
SO_ERROR: set the socket error code inside click. (Not recommended)
SO_DEBUG: enable debug mode for this socket
most other socket options will do nothing and return success

Parameters
sockfdThe control socket
optnameThe socket option to set
optvalA pointer to the value to set
optlenThe length of the option being set
Returns
0 on success
-1 on error with errno set
errno values:
EBADF: The socket descriptor is invalid
EINVAL: Either optval is null, or optlen is invalid, or optval is out of range
ENOPROTOOPT: the specified optname is not recognized