ntohs or ntohl
Prototype:
#include <resolv.h>
unsigned short int ntohs(unsigned short int network_short);
unsigned long int ntohl(unsigned long int network_long);
General Description: Converts the network byte order to the host's byte order.
Return Value: The converted value (16 bits or 32 bits).
Parameters
network_short The 16-bit value to convert.
network_long The 32-bit value to convert.
Possible Errors
(none)
Examples
struct sockaddr_in addr;
int client, addrlen=sizeof(addr);
client = accept(sockfd, &addr, &addrlen);
if ( client > 0 )
    printf("Connected %lX:%d\n", ntohl(addr.sin_addr),
        ntohs(addr.sin_port));