1

I have developed a program in an academic project. This program includes a client and a server portion and aims to allow two notebooks to exchange information in an adhoc network:

  1. The program should establish an adhoc connection with another computer
  2. The program should send a message to the other computer through the adhoc connection

I did the first step. I developed a program that uses Windows WLAN API to connect to an adhoc network. The problem is the second step. I want to use Sockets API to send the message. Therefore, I need the IP address of the other computer. How can I get the IP address of this computer in an adhoc network?

Carey Gregory
  • 6,836
  • 2
  • 26
  • 47

1 Answers1

0

I think you should be able to enumerate all the network interfaces connected to your network and dump the addresses known for each adapter. Something like this:

var addresses = Dns.GetHostEntry((Dns.GetHostName()))
                    .AddressList
                    .Where(ip => ip.AddressFamily == AddressFamily.InterNetwork)
                    .Select(ip => ip.ToString())
                    .ToArray();

Also take a look at ManagedWifi

Chibueze Opata
  • 9,856
  • 7
  • 42
  • 65