Set AI_PASSIVE only for listener
This commit is contained in:
@@ -304,9 +304,11 @@ int main (int argc, char **argv)
|
|||||||
.ai_family = AF_UNSPEC,
|
.ai_family = AF_UNSPEC,
|
||||||
.ai_socktype = SOCK_STREAM,
|
.ai_socktype = SOCK_STREAM,
|
||||||
.ai_protocol = IPPROTO_TCP,
|
.ai_protocol = IPPROTO_TCP,
|
||||||
.ai_flags = AI_PASSIVE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (listener)
|
||||||
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
struct addrinfo *ai = NULL;
|
struct addrinfo *ai = NULL;
|
||||||
|
|
||||||
if (getaddrinfo(host, port, &hints, &ai)) {
|
if (getaddrinfo(host, port, &hints, &ai)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user