Home |
Function socket |
Function socketAllocate a UDP, TCP, or RAW socket. SOCKET socket(int family, int type, int protocol); ParametersfamilyAddress format (AF_INET). typeProtocol type: SOCK_STREAM for TCP, SOCK_DGRAM for UDP, or SOCK_RAW for RAW. protocolIP protocol (for SOCK_RAW only). return valueReturns INVALID_SOCKET if no more sockets are available or a socket number. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. Error Codes further describes each error. Possible values for this function are:
This function returns a socket number which may later be used as an argument to the other socket and API functions. The number of sockets available at any one time are determined by the constants CFG_NUDPPORTS (UDP and RAW) and CFG_NTCPPORTS (TCP). When use of the socket is completed, closesocket or xn_abort (TCP only) should be called to make it available for other calls to function socket. Like the UNIX sockets environment, the TCP sockets are not useful until connect, listen, bind, or accept has been called.
|