artyomboyko
artyomboyko

Reputation: 2871

C socket multiple local ips

We have N local ip's on our server. I need to create socket connection using one of them. How can i do that ?

fd = socket(AF_INET, SOCK_STREAM, 0);
connect(fd, (struct sockaddr*)addr, sizeof(*addr));
// ...

Upvotes: 0

Views: 126

Answers (1)

user149341
user149341

Reputation:

bind() the socket to the appropriate local address before connecting.

Upvotes: 3

Related Questions