| |  iMatix home page | << | < | > | >> |  SFL Version 2.11 | 
#include "sflsock.h"
char *
socket_peeraddr (
    sock_t handle)
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".
{
#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
}
| | << | < | > | >> |  Copyright © 1996-2000 iMatix Corporation |