diff -u nsock.orig/src/nsock_connect.c nsock.modif/src/nsock_connect.c --- nsock.orig/src/nsock_connect.c 2008-05-06 22:29:43.000000000 +0200 +++ nsock.modif/src/nsock_connect.c 2006-01-21 17:58:30.000000000 +0100 @@ -53,7 +53,7 @@ * * ***************************************************************************/ -/* $Id: nsock_connect.c 2866 2005-09-12 05:35:14Z fyodor $ */ +/* $Id: nsock_connect.c,v 1.1.1.1 2006/01/21 16:58:30 evii Exp $ */ #include "nsock.h" #include "nsock_internal.h" @@ -79,7 +79,7 @@ #endif /* Now it is time to actually attempt the connection */ - if ((nse->iod->sd = (int) socket(sin->sin_family, + if ((nse->iod->sd = socket(sin->sin_family, (proto == IPPROTO_UDP)? SOCK_DGRAM : SOCK_STREAM, proto)) == -1) { perror("Socket troubles"); @@ -271,7 +271,7 @@ msiod *nsi = (msiod *) ms_iod; int ret = 1; struct sockaddr_storage sock; - int slen = sizeof(struct sockaddr_storage); + unsigned int slen = sizeof(struct sockaddr_storage); int res; assert(socklen > 0); diff -u nsock.orig/src/nsock_core.c nsock.modif/src/nsock_core.c --- nsock.orig/src/nsock_core.c 2008-05-06 22:29:43.000000000 +0200 +++ nsock.modif/src/nsock_core.c 2006-01-21 17:58:30.000000000 +0100 @@ -53,7 +53,7 @@ * * ***************************************************************************/ -/* $Id: nsock_core.c 2535 2005-01-31 20:40:45Z fyodor $ */ +/* $Id: nsock_core.c,v 1.1.1.1 2006/01/21 16:58:30 evii Exp $ */ #include "nsock_internal.h" #include "gh_list.h" @@ -209,7 +209,8 @@ void handle_connect_result(mspool *ms, msevent *nse, enum nse_status status) { - int optval, optlen = sizeof(int); + int optval; + unsigned int optlen = sizeof(int); char buf[1024]; msiod *iod = nse->iod; #if HAVE_OPENSSL @@ -455,9 +456,9 @@ max_chunk = nse->readinfo.num; if (!iod->ssl) { - /* Traditional read() - no SSL - using recv() because that works better on Windows */ + /* Traditional read() with no SSL */ do { - buflen = recv(iod->sd, buf, sizeof(buf), 0); + buflen = read(iod->sd, buf, sizeof(buf)); if (buflen == -1) err = socket_errno(); if (buflen > 0) { if (fscat(&nse->iobuf, buf, buflen) == -1) { @@ -944,7 +945,7 @@ int strlength = 0; char displaystr[256]; char errstr[256]; - + if (ms->tracelevel == 0) return; @@ -964,12 +965,17 @@ break; case NSE_TYPE_READ: - if (nse->status != NSE_STATUS_SUCCESS) - nsock_trace(ms, "Callback: %s %s %sfor EID %li [%s:%hi]", + if (nse->status != NSE_STATUS_SUCCESS) { + if (nsi->peerlen > 0) + nsock_trace(ms, "Callback: %s %s %sfor EID %li [%s:%hi]", nse_type2str(nse->type), nse_status2str(nse->status), errstr, nse->id, inet_ntop_ez(&nsi->peer, nsi->peerlen), nsi_peerport(nsi)); - else { + else + nsock_trace(ms, "Callback: %s %s %sfor EID %li (peer unspecified)", + nse_type2str(nse->type), nse_status2str(nse->status), + errstr, nse->id); + } else { str = nse_readbuf(nse, &strlength); if (ms->tracelevel > 1 && strlength < 80) { memcpy(displaystr, ": ", 2); @@ -977,11 +983,17 @@ displaystr[2 + strlength] = '\0'; replacenonprintable(displaystr + 2, strlength, '.'); } else displaystr[0] = '\0'; - nsock_trace(ms, "Callback: %s %s for EID %li [%s:%hi] %s(%d bytes)%s", - nse_type2str(nse->type), nse_status2str(nse->status), - nse->id, inet_ntop_ez(&nsi->peer, nsi->peerlen), - nsi_peerport(nsi), nse_eof(nse)? "[EOF]" : "", strlength, - displaystr); + + if (nsi->peerlen > 0) + nsock_trace(ms, "Callback: %s %s for EID %li [%s:%hi] %s(%d bytes)%s", + nse_type2str(nse->type), nse_status2str(nse->status), + nse->id, inet_ntop_ez(&nsi->peer, nsi->peerlen), + nsi_peerport(nsi), nse_eof(nse)? "[EOF]" : "", strlength, + displaystr); + else + nsock_trace(ms, "Callback %s %s for EID %li (peer unspecified) %s(%d bytes)%s", + nse_type2str(nse->type), nse_status2str(nse->status), + nse->id, nse_eof(nse)? "[EOF]" : "", strlength, displaystr); } break;