| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

socket_peeraddr

#include "sflsock.h"
char *
socket_peeraddr (
    sock_t handle)

Synopsis

Returns a string containing the peer host address for the specified connected socket. The string is formatted as a string "n.n.n.n". Returns the address of a static string or a buffer that is overwritten by each call. If sockets are not supported, or there was an error, returns the loopback address "127.0.0.1".

Source Code - (sflsock.c)

{
#if (defined (DOES_SOCKETS))
    static char
        peeraddr [NTOA_MAX + 1];        /*  xxx.xxx.xxx.xxx                  */
    struct sockaddr_in
        sin;                            /*  Address of peer system           */

    if (get peer addr (handle, &sin, NULL, 0))
        return ("127.0.0.1");
    else
      {
        strncpy (peeraddr, inet_ntoa (sin.sin_addr), NTOA_MAX);
        return  (peeraddr);
      }
#else
    return ("127.0.0.1");
#endif
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation