Ticket #373: net-tcpserver-and-client.patch

File net-tcpserver-and-client.patch, 1.0 KB (added by Olly Betts, 16 years ago)

Another patch to test, which also updates tcpclient.cc similarly.

  • net/tcpserver.cc

     
    167167    }
    168168
    169169    struct sockaddr_in addr;
     170    memset(&addr, 0, sizeof(addr));
    170171    addr.sin_family = AF_INET;
    171172    addr.sin_port = htons(port);
    172173    if (host.empty()) {
     
    191192                );
    192193        }
    193194
    194         memcpy(&addr.sin_addr, hostent->h_addr, sizeof(addr.sin_addr));
     195        memcpy(&addr.sin_addr, hostent->h_addr, hostent->h_length);
    195196    }
    196197
    197198    retval = bind(socketfd,
  • net/tcpclient.cc

     
    6868    }
    6969
    7070    struct sockaddr_in remaddr;
     71    memset(&remaddr, 0, sizeof(remaddr));
    7172    remaddr.sin_family = AF_INET;
    7273    remaddr.sin_port = htons(port);
    73     memcpy(&remaddr.sin_addr, host->h_addr, sizeof(remaddr.sin_addr));
     74    memcpy(&remaddr.sin_addr, host->h_addr, host->h_length);
    7475
    7576#ifdef __WIN32__
    7677    ULONG enabled = 1;