0

I have a server with 3 different NICs with 3 different IP addresses. I want to write a small socket program to select which NIC will be used to send out the message. I just want to know that is it possible or we can use only one NIC?

My socket server is a web server (of course, it is running on port 80 and can be accessed through the Internet). I created a socket (C#) and bind one of my IP address before making request to the web server. Unfortunately, I have no lucky, the request cannot be sent.

UPDATE: I Windows, how can I simultaneously use multiple NIC at the same time. I tried to bind IP to socket, but only one IP are working. Each individual works well when other is disable. I am looking forward for solution for this. Thanks!

Any advices from you are very appreciated. Thanks and regards.

ofecrpnr
  • 109
  • 1
  • 2
  • 10

1 Answers1

1

This answer is more C related, but it should be similar in C#.

Before you bind a socket on a machine you call getaddrinfo() which returns a pointer to a linked list of addresses. Then from there you choose which one to bind on. Your different NICs' addresses will be in there, so just pick the one you want and bind on that one.

EDIT: also this SO question might help

Choose one of many Internet connections for an application

Community
  • 1
  • 1
lmirosevic
  • 15,787
  • 13
  • 70
  • 116