diff options
Diffstat (limited to 'common/os_calls.c')
-rw-r--r-- | common/os_calls.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 07f378e5..500db201 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -60,6 +60,7 @@ #include "os_calls.h" #include "arch.h" +#include "log.h" /* for clearenv() */ #if defined(_WIN32) @@ -493,6 +494,7 @@ g_tcp_local_socket(void) void APP_CC g_tcp_close(int sck) { + char ip[256] ; if (sck == 0) { return; @@ -501,6 +503,8 @@ g_tcp_close(int sck) #if defined(_WIN32) closesocket(sck); #else + g_write_ip_address(sck,ip,255); + log_message(LOG_LEVEL_INFO,"An established connection closed to endpoint: %s", ip); close(sck); #endif } @@ -636,6 +640,8 @@ g_tcp_listen(int sck) int APP_CC g_tcp_accept(int sck) { + int ret ; + char ipAddr[256] ; struct sockaddr_in s; #if defined(_WIN32) signed int i; @@ -645,7 +651,14 @@ g_tcp_accept(int sck) i = sizeof(struct sockaddr_in); memset(&s, 0, i); - return accept(sck, (struct sockaddr *)&s, &i); + ret = accept(sck, (struct sockaddr *)&s, &i); + if(ret>0) + { + snprintf(ipAddr,255,"A connection received from: %s port %d" + ,inet_ntoa(s.sin_addr),ntohs(s.sin_port)); + log_message(LOG_LEVEL_INFO,ipAddr); + } + return ret ; } /*****************************************************************************/ |