tfBindNoCheck

Jump to: navigation, search

Table of Contents >> Programmer's Reference


#include <trsocket.h>


int tfBindNoCheck (
int socketDescriptor,
const struct sockaddr * addressPtr,
int addressLength
);


Function Description

tfBindNoCheck() assigns an address to an unnamed socket. When a socket is created with socket, it exists in an address family space but has no address assigned. tfBindNoCheck() requests that the address pointed to by addressPtr be assigned to the socket. Clients do not normally require that an address be assigned to a socket. However, servers usually require that the socket be bound to a "well known" address. The port number must be less than 32,768 (TM_SOC_NO_INDEX), or could be 0xFFFF (TM_WILD_PORT). Binding to the TM_WILD_PORT port number allows a server to listen for incoming connection requests on all the ports. This function is similar to bind(), except that bind() checks that the address that the user wants to bind to is a valid configured address on an interface; tfBindNoCheck() does not check for that, and allows the user to bind to any IP address.


Parameters

  • (int) socketDescriptor
    The socket descriptor to assign an IP address and port number to.
  • (const struct sockaddr *) addressPtr
    The pointer to the structure containing the address to assign.
  • (int) addressLength
    The length of the address structure.


Returns

  • TM_ENOERROR
    Success
  • TM_SOCKET_ERROR
    Failure


Note Note: TM_SOCKET_ERROR means that this socket call has failed and the errorCode has been set on the socket itself.

To retrieve the socket error the user must call tfGetSocketError(socketDescriptor).


Possible socket errors

  • TM_EADDRINUSE
    The specified address is already in use.
  • TM_EBADF
    'socketDescriptor' is not a valid descriptor.
  • TM_EINVAL
    One of the passed parameters is invalid, or the socket is already bound.
  • TM_EINPROGRESS
    tfBindNoCheck() is already running.


Table of Contents >> Programmer's Reference