/* * (c) Copyright, Real-Time Innovations, 2005-2024. * All rights reserved. * * No duplications, whole or partial, manual or electronic, may be made * without express written permission. Any such copies, or * revisions thereof, must display this notice unaltered. * This code contains trade secrets of Real-Time Innovations, Inc. */ #ifndef osapi_socket_h #define osapi_socket_h #include /* Architectures that require u_char (standard POSIX header) */ #if (defined(RTI_UNIX) || defined(RTI_VXWORKS) || defined(RTI_LYNX) \ || defined(RTI_QNX) || defined(RTI_INTY) || defined(RTI_OPENVMS)) #include #endif #if (defined(RTI_QNX)) #include #endif #if (defined(RTI_VXWORKS) || defined(RTI_LYNX)) #if (defined(RTI_VX653)) #include #endif #include #elif defined(RTI_INTY) #include #include #include #include #elif (defined(RTI_UNIX) || defined(RTI_QNX)) #include #include #include #elif (defined(RTI_WIN32) || defined(RTI_WINCE)) #include #include #elif defined(RTI_INTIME) #include #include #endif #if defined(RTI_VXWORKS) #include #if !defined(RTI_VX653) #include #endif #elif defined(RTI_LYNX) #include #if !defined(RTI_LYNXOS_SE) && !defined(RTI_LYNX500) #include #endif #endif #include "log/log_common.h" #include "osapi/osapi_log.h" #include "osapi/osapi_type.h" #ifdef __cplusplus extern "C" { #endif #if defined(RTI_VX653) #if (RTI_VX653 >= 2501) struct sockaddr; #else typedef unsigned int socklen_t; #endif struct sockaddr_in; struct in_addr; #endif /** @internal \file * \brief Socket * Even though a socket is represented as an int and not as a full blown * class, we still need methods to manipulate the socket, EXCEPT methods * to actually write and read the socket. */ /** @internal \defgroup RTIOsapiSocketClass int * \ingroup RTIOsapiModule * \brief OS independent encapsulation of IP (can be UDP or TCP) socket. */ /** @internal \ingroup RTIOsapiSocketClass * @brief Initialize and query availability of Netio transport * * This function can be used to query the availability of a netio transport * (currently only NETIO_IP), and initialize that implementation. * * The function will return RTI_TRUE if successful, RTI_FALSE if the requested * transport is not available, or the initialization was unsuccessful. * * This function must be called at least once before any other netio * functions; it is idempotent so that it can be called multiple times * without side effects. */ extern RTIOsapiDllExport RTIBool RTIOsapiSocketModule_init(void); /** @internal \ingroup RTIOsapiSocketClass * @brief Cleanup state of Netio package (WindowsNT/pSOS only) * * This function is only needed in WindowsNT applications. Call it * after all use of the Netio package has completed. This function is * also needed in pSOS for shutting down the socket manager */ extern RTIOsapiDllExport void RTIOsapiSocketModule_finalize(void); /** @internal \ingroup RTIOsapiSocketClass * @brief Available types of sockets. */ typedef enum { RTI_OSAPI_SOCKET_TYPE_UDPv4 = 0x00, RTI_OSAPI_SOCKET_TYPE_TCPv4 = 0x01, RTI_OSAPI_SOCKET_TYPE_UDPv4_OVL = 0x02, RTI_OSAPI_SOCKET_TYPE_TCPv4_OVL = 0x03, RTI_OSAPI_SOCKET_TYPE_UDPv6 = 0x10, RTI_OSAPI_SOCKET_TYPE_TCPv6 = 0x11 } RTIOsapiSocketType; /** @internal \ingroup RTIOsapiSocketClass * @brief OS independent function to create a socket for UDPv4, TCPv4, UDPv6, * TCPv6. * * The function will return a socket descriptor. If this descriptor is greater * than RTI_INT32_MAX or if there's an error, we return a negative value. */ extern RTIOsapiDllExport int RTIOsapiSocket_create( RTIOsapiSocketType socketType); /** @internal \ingroup RTIOsapiSocketClass * \brief Used to specify that os default be used to specify socket buffer size. */ #define RTI_OSAPI_SOCKET_BUFFER_SIZE_OS_DEFAULT (-1) /** @internal \ingroup RTIOsapiSocketClass * \brief Address family. */ typedef RTI_UINT32 RTIOsapiSocketAFKind; typedef RTI_UINT32 RTIOsapiSocketAFMask; #define RTI_OSAPI_SOCKET_AF_INET (RTIOsapiSocketAFKind)(0x0001 << 0) #define RTI_OSAPI_SOCKET_AF_INET6 (RTIOsapiSocketAFKind)(0x0001 << 1) #define RTI_OSAPI_SOCKET_AF_MASK_NONE (RTIOsapiSocketAFKind)(0x0) /** @internal \ingroup RTIOsapiSocketClass * \brief Returns the address family AF_INET or AF_INET6 from a * RTIOsapiSocketAFKind */ extern RTIOsapiDllExport int RTIOsapiSocket_addressFamilyFromKind( RTIOsapiSocketAFKind kind); /** @internal \ingroup RTIOsapiSocketClass * Specify either blocking or nonblocking when calling RTIOsapiSetSockOpt() * with RTI_OSAPI_SOCKET_OPTION_BLOCK option. * * @see RTIOsapiSocket_setOption */ typedef enum { /** If RTIOsapiSocket_setOption(RTI_OSAPI_SOCKET_OPTION_BLOCK) operation failed, the errno will be set to this. */ RTI_OSAPI_SOCKET_BLOCKING_ERROR = -1, /** Read operation will come back right away. */ RTI_OSAPI_SOCKET_NONBLOCKING = 0, /** Block on the socket until data is received. */ RTI_OSAPI_SOCKET_BLOCKING = 1 } RTIOsapiSocketBlockingType; /** @internal \ingroup RTIOsapiSocketClass * * OS independent abstraction for all socket options RTI programs may use. * The following is the list of all supported socket options. Values are * bit-specific so that we can pass 1 option value with all desired options * at once. * * @see RTIOsapiSetSockOpt RTIOsapiGetSockOpt */ typedef enum { /** Use the default socket state. */ RTI_OSAPI_SOCKET_OPTION_DEFAULT = 0x0, /** Allow multiple sockets to bind to the same port. @see RTIOsapiSocket_bind */ RTI_OSAPI_SOCKET_OPTION_REUSEPORT = 0x1, /** Specify the size of the send buffer for the socket. Both the default and the maximum are OS dependent. */ RTI_OSAPI_SOCKET_OPTION_SENDBUF = 0x2, /** Specify the size of the recv buffer for the socket. Both the default and the maximum are OS dependent. */ RTI_OSAPI_SOCKET_OPTION_RECVBUF = 0x4, /** Leave a multicast group. As far as we know, this is not necessary if you are going to destroy the socket, coz OS automatically takes care of it. */ RTI_OSAPI_SOCKET_OPTION_DROP_MEMBERSHIP = 0x8, /** Join a multicast group. Make sure you don't join a reserved multicast address! */ RTI_OSAPI_SOCKET_OPTION_ADD_MEMBERSHIP = 0x10, /** Specify the maximum number of hops for the multicast packets out of this socket. @see intTTL */ RTI_OSAPI_SOCKET_OPTION_MULTICAST_TTL = 0x20, /** Specify the outgoing interfaces for the multicast packets out of this socket. By default, packets go out on the "primary" interface, whatever that may be. */ RTI_OSAPI_SOCKET_OPTION_MULTICAST_IF = 0x40, /** Turn on/off the loopback capability of the stack for multicast packets out of this socket. By default, the stack copies the multicast packets to loopback interface if there is an application on the local node that wants to receive data for that multicast address and port. Turning the loopback off can spare the stack from doing a lot of work, but you must be certain that the application does not need to receive that data, because the data may not even be received on the interface, depending on the OS. Not all OSes support this option. */ RTI_OSAPI_SOCKET_OPTION_MULTICAST_LOOPBACK = 0x80, /** Turn on/off the blocking mode of this socket. */ RTI_OSAPI_SOCKET_OPTION_BLOCK = 0x100, /** Turn off the use of collision-avoidance algorithm. */ RTI_OSAPI_SOCKET_OPTION_TCP_NODELAY = 0x200, /** Enables linger on close if data is present */ RTI_OSAPI_SOCKET_OPTION_LINGER = 0x800, /** Set IPv4 TOS field or IPv6 Traffic Class field. */ RTI_OSAPI_SOCKET_OPTION_PRIORITY = 0x1000, /** Force IPv6 socket to be V6-only (req'd on Linux) */ RTI_OSAPI_SOCKET_OPTION_V6ONLY = 0x2000, /** The UDP checksum is turned on by default. In some platforms such as * Linux and Windows it can be turned off by setting the no checksum option * to 1. */ RTI_OSAPI_SOCKET_OPTION_UDP_NOCHECKSUM = 0x4000, /* Forces the exclusive use of a port in Windows so other sockets cannot be * forcibly bound to the same address and port. */ RTI_OSAPI_SOCKET_OPTION_EXCLUSIVEADDRUSE = 0x8000, /** * If enabled, the IP_TOS ancillary message is passed with incoming * packets */ RTI_OSAPI_SOCKET_OPTION_RECV_PRIORITY = 0x10000, } RTIOsapiSocketOption; #if (defined(RTI_UNIX) || defined(RTI_VXWORKS) || defined(RTI_INTIME)) #define RTIOsapiSocketMulticastLoopbackFlag u_char #define RTIOsapiSocketBroadcastFlag int typedef unsigned char RTIOsapiSocketTTL; #elif defined(RTI_PSOS) typedef unsigned char RTIOsapiSocketTTL; typedef unsigned char RTIOsapiSocketMulticastLoopbackFlag; #define RTIOsapiSocketBroadcastFlag int #elif defined(RTI_NETOS) typedef unsigned char RTIOsapiSocketTTL; typedef u_char RTIOsapiSocketMulticastLoopbackFlag; typedef int RTIOsapiSocketBroadcastFlag; #elif defined(RTI_LYNX) typedef unsigned char RTIOsapiSocketTTL; typedef u_char RTIOsapiSocketMulticastLoopbackFlag; typedef int RTIOsapiSocketBroadcastFlag; #elif defined(RTI_QNX) typedef unsigned char RTIOsapiSocketTTL; typedef u_char RTIOsapiSocketMulticastLoopbackFlag; typedef int RTIOsapiSocketBroadcastFlag; #elif defined(RTI_INTY) typedef unsigned char RTIOsapiSocketTTL; typedef u_char RTIOsapiSocketMulticastLoopbackFlag; typedef int RTIOsapiSocketBroadcastFlag; #elif defined(RTI_OPENVMS) typedef unsigned char RTIOsapiSocketTTL; typedef u_char RTIOsapiSocketMulticastLoopbackFlag; typedef int RTIOsapiSocketBroadcastFlag; #elif defined(RTI_WIN32) || defined(RTI_WINCE) #define RTIOsapiSocketTTL int #define RTIOsapiSocketMulticastLoopbackFlag BOOL #define RTIOsapiSocketBroadcastFlag BOOL #else #error "Need to port" #endif #if defined(RTI_WIN32) || defined(RTI_WINCE) #define RTIOsapiSocket_close closesocket /** @internal \ingroup RTIOsapiSocketClass * * Get the last error code set. To make sure you are not reading an * error code corresponding to a previous call, set the error code to * RTI_OSAPI_SOCKET_NOERROR because making a netio call. This call is not * thread-safe on some OSes at the moment. * * @see RtiNetioErrnoSet RTI_OSAPI_SOCKET_NOERROR */ #define RTIOsapiSocket_getError WSAGetLastError /** @internal \ingroup RTIOsapiSocketClass * * Set the system level error code. * * @param ErrorNumber Error code. * * @see RtiNetioErrnoGet */ #define RTIOsapiSocket_setError WSASetLastError #define RTI_OSAPI_SOCKET_MULTICAST_LOOPBACK_ON TRUE #define RTI_OSAPI_SOCKET_MULTICAST_LOOPBACK_OFF FALSE #define RTI_OSAPI_SOCKET_BROADCAST_ON TRUE #define RTI_OSAPI_SOCKET_BROADCAST_OFF FALSE #else #if defined(RTI_VXWORKS) || defined(RTI_VX653) #ifndef errno #define errno errnoGet() #endif #endif #define RTIOsapiSocket_close close #define RTIOsapiSocket_getError() errno #define RTIOsapiSocket_setError(x) errno = (x) #define RTI_OSAPI_SOCKET_BROADCAST_ON 1 #define RTI_OSAPI_SOCKET_BROADCAST_OFF 0 #define RTI_OSAPI_SOCKET_MULTICAST_LOOPBACK_ON 1 #define RTI_OSAPI_SOCKET_MULTICAST_LOOPBACK_OFF 0 #endif /** @internal \ingroup RTIOsapiSocketClass * @brief Used to specify that os maximum be used to specify socket buffer size. */ #define RTI_OSAPI_UDP_SOCKET_BUFFER_SIZE_OS_MAX (-2) /** @internal \ingroup RTIOsapiSocketClass * @brief Used to specify that os default be used to specify socket buffer size. */ #define RTI_OSAPI_UDP_SOCKET_BUFFER_SIZE_OS_DEFAULT (-1) #ifndef RTI_AIX /** @internal \ingroup RTIOsapiSocketClass * @brief Default value of send_socket_buffer_size. */ #define RTI_OSAPI_UDP_SEND_SOCKET_BUFFER_SIZE_DEFAULT 2097152 /** @internal \ingroup RTIOsapiSocketClass * @brief Default value of recv_socket_buffer_size. */ #define RTI_OSAPI_UDP_RECV_SOCKET_BUFFER_SIZE_DEFAULT 2097152 #else /* On AIX, setting a value higher than the configured maximum causes the * socket creation to fail, as opposed to on other platforms which will still * create the socket by just use a smaller value for the socket buffer size. * 1048576 is the common OOB default maximum on AIX, so we set that as our * default instead of 2097152 like for the other platforms. Using a value that * we know will likely fail will cause us to have to unnecessarily search for * the maximum. */ #define RTI_OSAPI_UDP_SEND_SOCKET_BUFFER_SIZE_DEFAULT 1048576 #define RTI_OSAPI_UDP_RECV_SOCKET_BUFFER_SIZE_DEFAULT 1048576 #endif #if defined(RTI_DARWIN) #define RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR "kern.ipc.maxsockbuf" #define RTI_OSAPI_MAX_RECV_SOCKET_BUFFER_SIZE_VAR \ RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR #elif defined(RTI_QNX) #if defined(__QNX__) && (__QNX__ >= 800) #define RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR "kern.ipc.maxsockbuf" #else #define RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR "kern.sbmax" #endif #define RTI_OSAPI_MAX_RECV_SOCKET_BUFFER_SIZE_VAR \ RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR #elif defined(RTI_LINUX) #define RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR "net.core.wmem_max" #define RTI_OSAPI_MAX_RECV_SOCKET_BUFFER_SIZE_VAR "net.core.rmem_max" #elif defined(RTI_AIX) #define RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR "sb_max" #define RTI_OSAPI_MAX_RECV_SOCKET_BUFFER_SIZE_VAR \ RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR #else #define RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR NULL #define RTI_OSAPI_MAX_RECV_SOCKET_BUFFER_SIZE_VAR \ RTI_OSAPI_MAX_SEND_SOCKET_BUFFER_SIZE_VAR #endif /** @internal \ingroup RTIOsapiSocketClass * * Behave like UNIX ioctl() on a socket. * * Hides WinSock ioctlsocket() and presents the same interface as UNIXs * ioctl(). Always returns -1 on OS's that do not have a call equivalent * to a UNIX ioctl (e.g. NetOS). * * @param sd A operating system socket. * @param request The option to set. * @param total Data associated with the request type * * @return Returns int just like ioctl() and ioctlsocket(). Please note * that the return code is OS-specific. Returns -1 when the underlying * OS has no UNIX-like ioctl. */ extern RTIOsapiDllExport int RTIOsapiSocket_ioctl( int sd, int request, int *total); /** @internal \ingroup RTIOsapiSocketClass * Set socket/file descriptor to non-blocking. * * Use notBlocking = 0 for Blocking notBlocking = 1 for Non-Blocking * * @param df Operating system socket. * @param Blocking To set socket to either blocking or non-blocking. * * @see RTIOsapiSocketBlockingType */ extern RTIOsapiDllExport int RTIOsapiSocket_setBlocking( int fd, RTIOsapiSocketBlockingType Blocking); /** @internal \ingroup RTIOsapiSocketClass * OS independent function to get socket option. * * @param s Socket * @param optType Desired action. * @param optVal Pointer to the desired value corresponding to the * optType. * @param optLenPtr Pointer to the integer to return the actual value. * Don't set the initial value to 0! * * @return 0 if successful, -1 if error * * @see RTIOsapiSocketOption RTIOsapiSocket_setOption */ extern RTIOsapiDllExport int RTIOsapiSocket_getOption( int s, RTIOsapiSocketOption optType, char *optVal, unsigned int *optLenPtr); /** @internal \ingroup RTIOsapiSocketClass * OS independent function to setsocket option. * * @param s Socket * @param optType Desired action. * @param optVal Pointer to the desired value corresponding to the * optType. * @param optLen Length of the optVal in bytes. * * @return 0 if successful, -1 if error * * @see RTIOsapiSocket_getOption */ extern RTIOsapiDllExport int RTIOsapiSocket_setOption( int s, RTIOsapiSocketOption optType, const char *optVal, unsigned int optLen); /** @internal \ingroup RTIOsapiSocketClass * * @brief Invalid differentiated service field. */ #define RTI_OSAPI_SOCKET_INVALID_DIFF_SERV -1 /** @internal \ingroup RTIOsapiSocketClass * * @brief Max DiffServ value. */ #define RTI_OSAPI_SOCKET_MAX_DIFF_SERV 0xFF /** @internal \ingroup RTIOsapiSocketClass * * @brief Receive data from a socket. * * @param s \b In. Socket. * @param buffer \b Out. Pointer to the buffer where the data will be stored. * @param bufferSize \b In. Size of the buffer where the data will be stored. * @param flags \b In. Specifies the type of message reception. * @param fromAddress \b Out. If fromAddress is not NULL, this source address is * filled in with the IP address that sent the packet received on the socket. * @param addressLen \b InOut. The argument addressLen must be initialized by * the caller to the size of the buffer associated with fromAddress, and it is * modified on return to indicate the actual size of the source address. Cannot * be NULL if fromAddress is not NULL. * @param diffServ \b Out. If different than NULL, it is initialized to the * differentiated services field value associated with the received packet. * If for some reason, the diffServ value cannot be retrieved from the packet, * *diffServ will be set to RTI_OSAPI_SOCKET_INVALID_DIFF_SERV (-1). * * @details Extracting the diffServ from the IP packets is only supported by RTI * in platforms where RTI_DIFF_SERV_PER_MSG is defined. * * If extracting the diffServ is not supported *diffServ will be set to * RTI_OSAPI_SOCKET_INVALID_DIFF_SERV. * * @return -1 on failure; otherwise, returns number of bytes received. */ extern RTIOsapiDllExport int RTIOsapiSocket_recvFrom( int sd, void *buffer, size_t bufferSize, int flags, struct sockaddr *fromAddress, socklen_t *addressLen, int *diffServ); /** @internal \ingroup RTIOsapiSocketClass * OS independent function to setsocket option. * * @param s Socket * @param optType Desired action. * @param optVal Pointer to the desired value corresponding to the * optType. * @param optLen Length of the optVal in bytes. * @param family RTI_OSAPI_SOCKET_AF_INET or RTI_OSAPI_SOCKET_AF_INET6. * * @return 0 if successful, -1 if error * * @see RTIOsapiSocket_getOption */ extern RTIOsapiDllExport int RTIOsapiSocket46_setOption( int s, RTIOsapiSocketOption optType, const char *optVal, unsigned int optLen, RTIOsapiSocketAFKind family); /** @internal \ingroup RTIOsapiSocketClass * * @brief Send single buffer of data to a socket. * * @param sd \b In. Socket. * @param buffer \b In. Pointer to the buffer containing the data to be sent. * @param bufferSize \b In. Size of the buffer containing the data to be sent. * @param flags \b In. Specifies the type of message transmission. * @param address \b Out. This is the destination address where the data will be * sent. Cannot be NULL. * @param addressLen \b InOut. The argument addressLen must be initialized by * the caller to the size of the buffer associated with address. Cannot be NULL. * * @return The number of bytes successfully sent, or -1 in case of failure. */ extern RTIOsapiDllExport int RTIOsapiSocket_sendTo( int sd, const void *buffer, size_t bufferSize, int flags, const struct sockaddr *address, socklen_t addressLen); /** @internal \ingroup NDDS_OsapiSocketComponent * @brief Ignore unreachable ICMP destinations messages * * Sockets that are used to send and receive concurrently (e.g. for STUN * in WAN transport) require this functionality. Otherwise, the receive * thread will unblock with the error WSAECONNRESET every time a send * operation on the same socket cannot reach its final detination. * * see http://support.microsoft.com/kb/263823 * * @param socket Socket * * @return 0 on success or -1 if there is an error. */ extern RTIOsapiDllExport int RTIOsapiSocket_ignore_port_unreachable_on_receive( int socket); /** @internal \ingroup RTIOsapiSocketClass * * @brief Assign a port number to a socket. * * Bind a port to a socket. Fills in sockAddr. If the passed port * number is 0, then the system will assign a new port number. If the * bind succeeds, the bound port number is returned, and is also * available as ntohs(sockAddr->sin_port). This is only necessary if the * socket will receive data. */ extern RTIOsapiDllExport unsigned int RTIOsapiSocket_bind( int sd, struct sockaddr_in *sockAddr, unsigned int portnum); /** @internal \ingroup RTIOsapiSocketClass * * @brief Assign a port number and an IP address to a socket. * * Bind a ip/port to a socket. Fills in sockAddr. If the passed port number is * 0, then the system will assign a new port number. If the bind succeeds, the * bound port number is returned, and is also available as * ntohs(sockAddr->sin_port). This is only necessary if the socket will receive * data. */ extern RTIOsapiDllExport unsigned int RTIOsapiSocket_bindWithIP( int sd, struct sockaddr_in *sockAddr, unsigned int ip, unsigned int portnum); /* \ingroup RTIOsapiSocketClass * @brief Converts a host name into an internet address. * * If the input host name is NULL this function will return * the address of the host whose name was found using * gethostname. If RTIOsapiSocket_g_getHostByName is non-NULL (used for * testing), we will use this implementation for gethostbyname rather than * calling RTIOsapiSocket_getHostByNameOS. * * @return 0 if successful, -1 if error */ extern RTIOsapiDllExport int RTIOsapiSocket_getHostByName( struct in_addr *address_out, const char * hostName_in); typedef int (*RTIOsapiSocket_getHostByName_Fcn)( struct in_addr *address_out, const char *address_in); /*i \ingroup RTIOsapiSocketClass * @brief Set the value of RTIOsapiSocket_g_getHostByName. TEST only. * * @param myGetHostByName Function pointer to set RTIOsapiSocket_g_getHostByName * to. */ extern RTIOsapiDllExport void RTIOsapiSocket_setGetHostByName( RTIOsapiSocket_getHostByName_Fcn myGetHostByName); /* \ingroup RTIOsapiSocketClass * @brief Implementation of gethostbyname * * Converts a host name into an internet address. * * @param address_out Out. Populated with address of hostName_in * @param hostName_in Hostname to resolve into address. * @return 0 if successful, -1 if error. */ extern RTIOsapiDllExport int RTIOsapiSocket_getHostByNameOS( struct in_addr *address_out, const char *hostName_in); /* \ingroup RTIOsapiSocketClass * @brief Gets a connected socket and a client address given a listening socket. * * @param clientAddressOut the client address. Can be NULL only if * isSocketAlreadyAccepted is false. * @param clientAddressLengthInOut the client address length. The caller must * initialize it to contain the size (in bytes) of the structure pointed to by * clientAddressOut; on return, it will contain the actual size of the peer * address. Can be NULL only if clientAddressOut is NULL. * @param socketIn the listening socket * @param isSocketAlreadyAccepted true if the listening socket is already * accepted * * @return the connected socket file descriptor. If this descriptor is greater * than RTI_INT32_MAX or if there's an error, we return a negative value. */ extern RTIOsapiDllExport int RTIOsapiSocket_getAcceptedSocketAndClientAddress( struct sockaddr *clientAddressOut, socklen_t *clientAddressLengthInOut, int socketIn, RTIBool isSocketAlreadyAccepted); #if !defined(RTI_WIN32) && !defined(RTI_VXWORKS) && !defined(RTI_INTY) \ && !defined(RTI_AIX) /* * Only a subset of platforms support configuring the socket buffer sizes to * the OS maximum, leaving us to figure out that max value. See * RTIOsapiSocket_getSocketBufferSizes */ #define RTI_OSAPI_OS_SUPPORTS_MAX_SOCKET_BUFFER_SIZES 1 #endif /* @internal \ingroup RTIOsapiSocketClass * @brief Get the values that should be used to create send and * receive socket buffers. * * If either of the input values are -1 then the output value will be set to the * OS default value that is used when a socket is created. * * If either of the input values are -2 then one of two things will happen: * - If the OS supports retrieving the max value, then the input value will be * replaced with the OS max value * - If the OS does not support retrieving the max value then the input value * will be replaced with RTI_OSAPI_UDP_SEND_SOCKET_BUFFER_SIZE_DEFAULT * or RTI_OSAPI_UDP_RECV_SOCKET_BUFFER_SIZE_DEFAULT. * If the configured values exceed the maximum allowed by the OS, then they will * be reduced to the maximum and a warning will be printed. * * @param socketType \b In. The type of socket. * @param configuredSendBufferSize \b InOut. The configured send socket buffer * size. It will be resolved to the value that should be used whenever * creating send sockets based on the rules in the above description. * @param configuredReceiveBufferSize \b InOut. The configured receive socket * buffer size. It will be resolved to the value that should be used * whenever creating send sockets based on the rules in the above * description. * * @return RTI_TRUE if successful, RTI_FALSE if error. */ extern RTIOsapiDllExport RTIBool RTIOsapiSocket_getSocketBufferSizes( RTIOsapiSocketType socketType, int *configuredSendBufferSize, int *configuredReceiveBufferSize); #ifdef __cplusplus } /* extern "C" */ #endif #include "osapi/osapi_socket_impl.h" #endif /* osapi_socket_h */