X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcnet.c;h=c4d6d9d7a653a5f00575a4cefcc0daa9541b61f3;hb=4d35af3be05cacf69ca4bd634973cdcd25118e98;hp=68a820f6316ec79b5fdb6dc95dc31a817f849b5f;hpb=e14cef8f772a6f73f05254ae220a3a83981ea753;p=silc.git diff --git a/lib/silcutil/silcnet.c b/lib/silcutil/silcnet.c index 68a820f6..c4d6d9d7 100644 --- a/lib/silcutil/silcnet.c +++ b/lib/silcutil/silcnet.c @@ -20,6 +20,9 @@ /* * $Id$ * $Log$ + * Revision 1.2 2000/10/31 19:48:32 priikone + * A LOT updates. Cannot separate. :) + * * Revision 1.1 2000/09/13 17:45:16 priikone * Splitted SILC core library. Core library includes now only * SILC protocol specific stuff. New utility library includes the @@ -149,8 +152,9 @@ int silc_net_create_connection(int port, char *host) return -1; } - /* Set appropriate option */ + /* Set appropriate options */ silc_net_set_socket_opt(sock, IPPROTO_TCP, TCP_NODELAY, 1); + silc_net_set_socket_opt(sock, SOL_SOCKET, SO_KEEPALIVE, 1); SILC_LOG_DEBUG(("Connection created")); @@ -205,8 +209,9 @@ int silc_net_create_connection_async(int port, char *host) } } - /* Set appropriate option */ + /* Set appropriate options */ silc_net_set_socket_opt(sock, IPPROTO_TCP, TCP_NODELAY, 1); + silc_net_set_socket_opt(sock, SOL_SOCKET, SO_KEEPALIVE, 1); SILC_LOG_DEBUG(("Connection operation in progress")); @@ -304,3 +309,13 @@ void silc_net_check_host_by_sock(int sock, char **hostname, char **ip) memcpy(*ip, host_ip, strlen(host_ip)); SILC_LOG_DEBUG(("Resolved IP address `%s'", *ip)); } + +/* Return name of localhost. */ + +char *silc_net_localhost() +{ + char hostname[256]; + if (!gethostname(hostname, sizeof(hostname))) + return strdup(hostname); + return NULL; +}