I am trying to make a TCP chat program, but instead of having people enter in the ip of the computer they wish to talk to everytime, i would like the program to be able to listen on all ip addresses, so that it will provide for a better user experience, and that i can have chat rooms with multiple people joining. I have the code working with entering in ips, however, when i use the IPAddress.any command it will not send messages. has anyone else done this?
Any help is greatly appreciated.
Thanks
~Matt

Recommended Answers

All 3 Replies

IPAddress.Any will automatically choose the network interface for you. To listen on a certain interface you have to use the correct IP.

You need to specify the IP address on which you want to listen, instead of IPAddress.Any.

For example,

For Each list In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
    For Each ip In list.GetIPProperties().UnicastAddresses
        Console.WriteLine(ip.Address)
    Next
Next

so in a chat tcp chat program, what would be the most efficient way of connecting more then two users?

>so in a chat tcp chat program, what would be the most efficient way of connecting more then two users?

Read post #2 (Code).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.