getsockname

Jump to: navigation, search

Table of Contents >> Programmer's Reference


#include <trsocket.h>


int getsockname (
int socketDescriptor,
struct sockaddr * myAddressPtr,
int * addressLengthPtr
);


Function Description

This function returns to the caller the local IP address/port number that we are using on a given socket.


Parameters

  • socketDescriptor
    The socket descriptor we wish to inquire about.
  • fromAddressPtr
    The pointer to the structure where the address information will be stored.
  • addressLengthPtr
    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_EBADF
    The socket descriptor is invalid.
  • TM_EINVAL
    One of the parameters is invalid.


Table of Contents >> Programmer's Reference