| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflsock.h" char * socket_localaddr ( sock_t handle)
Returns a string containing the local 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".
{ #define NTOA_MAX 16 #if (defined (DOES_SOCKETS)) static char localaddr [NTOA_MAX + 1]; /* xxx.xxx.xxx.xxx */ struct sockaddr_in sin; /* Address of local system */ if (get sock addr (handle, &sin, NULL, 0)) return ("127.0.0.1"); else { strncpy (localaddr, inet_ntoa (sin.sin_addr), NTOA_MAX); return (localaddr); } #else return ("127.0.0.1"); #endif }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |