Skip to content
  • LRN's avatar
    socket test: Use loopback for connecting, not 0.0.0.0 · c00724d5
    LRN authored
    getsockname() returns the address that the socket was bound to.
    If it was bound to INADDR_ANY, getsockname() will stubbornly return INADDR_ANY
    (and someport - that one is valid).
    Subsequent connection attempts to INADDR_ANY:someport will fail with winsock.
    Actually, it doesn't make even sense to connect to INADDR_ANY at all
    (where is the socket connecting to? To a random interface of the host?),
    so this is just a straight-up change, without platform-specific ifdefing.
    
    Use loopback instead of INADDR_ANY. To ensure that binding and creation
    of INADDR_ANY is still tested, use two addresses: bind to INADDR_ANY,
    but connect to loopback, with the port number that we got from the bound
    address.
    c00724d5