diff --git a/server.c b/server.c index 474de73..21b990e 100644 --- a/server.c +++ b/server.c @@ -198,8 +198,9 @@ int main(int argc, const char *argv[]){ while ((csock = accept(sock, (struct sockaddr *)&client_addr,&client_addr_len)) >= 0) { int fd; - /*inet_ntoa is not reentrant function. do not use it in signal handler.*/ - printf("Connect : %s\n",(inet_ntoa(client_addr.sin_addr))); + char ip_buf[INET_ADDRSTRLEN]; + char * msg = inet_ntop(AF_INET,&addr.sin_addr,ip_buf,sizeof(ip_buf)); + fprintf(stderr,"Connected on : %s:%d\n",msg == NULL ? "(null)" : msg , ntohs(addr.sin_port)); if((fd = read_request(csock,buf,bufsize)) > 0){ send_response(csock,fd,buf,bufsize); close(fd);