PDA

Click to See Complete Forum and Search --> : Chat program


Arachnid13
Apr 30th, 2007, 10:19 AM
Is it possible to broadcast a message to all ports on a computer? The other user will be listening on a port on their machine but I will not know the port only the IP so if i can broadcast a message to all ports and then get the port that replies i will see which port the other user is listening on. Don't just say "why cant you find out the port beforehand or set one in particular for the program to use" as not knowing the ports is one of the requirements ive set myself for this project.

DigiRev
Apr 30th, 2007, 11:27 AM
No, you can't send data to all ports in one go that I know of.

Is this VB6?

What you need to make is a port-scanner type program. Send connection requests to each port one at a time and wait until one connects. Then determine if that port is the right one.

A lot of computers will have some ports open that are not what you want. These are usually windows services. They might also be running other servers on their computer, like maybe FTP, or HTTP.

The best way to verify this is by making a "test" message in your program. For example, when you connect to a port, send a "SCAN_TEST" message or something. Then have the program respond with "TEST_OK" or something like that. Then you know that it is indeed your program running on that port.

However, port scanning is also considered 'malicious' by a lot of people and if they are running a firewall it will pick this up right away.

It's definitely the most un-ideal way to setup a chat system. Setting a port, or at least a port range from the start is the best way, but you said you didn't want to do that, so...

Arachnid13
May 1st, 2007, 04:07 AM
Thanks DigiRev, yea this is VB6, i had thought of using a port scanner but like you said firewalls would pose a serious problem there. One of the big issues I've had before is with port forwarding, for example i give my winsock server/client program to a friend and he gives me his ip address and the port he's listening on but when i try to connect to that port it can not connect as his isp has forwarded the port, similarly when he connects to my ip and port and sets the port he's using to "12345" for example, he can connect but if i check the "RemotePort" property of the winsock it returns a different port, so in cases like these is there anyway of finding the port without connecting to someone who doesnt "suffer" from port forwarding and have them connect back to you after they've checked which port your using? in fact can you even do that? say the port "12345" was remapped to "54321", well then the winsock would have to disconnect in order to listen so whats to stop the port changing again when it reconnects to say "33333"?

Arachnid13
May 1st, 2007, 04:10 AM
woops just realised i was calling it port forwarding... i meant port redirecting!

DigiRev
May 1st, 2007, 09:25 PM
First of all, I'd recommend signing up for a free DNS name from www.no-ip.com and downloading the free client. Then you can use static DNS names instead of having to pass IP address back and forth. You could just connect to: friend.no-ip.com and it will always point to his computer.

2nd, I've personally, never heard of an ISP remapping or forwarding ports. Your friend might be behind a router. If he is, then he needs to do port forwarding himself by going to his router settings. He can usually do this by going to:
http://192.168.0.1
http://192.168.1.1

Or whatever the IP of his router is. By default, it's usually one of the above. He will need to go to the port forwarding settings, enter his network IP and the port to use, and enable it.

3rd, if you are listening for a connection, and your friend connects to you, .RemotePort on your end will not be the same as the port your friend connected on.

For example:

You listen on port 1234
Your friend connects to you on port 1234
Your .RemotePort will not be 1234. It will be one that Windows has assigned.

xera
May 3rd, 2007, 08:16 AM
First of all, I'd recommend signing up for a free DNS name from www.no-ip.com and downloading the free client. ...

Can you use no-ip without entering your credit card details? I couldn't get it to work - luckily I was refered to www.dyndns.com, it's easy to use, free, plus I found the source code for two IP Update Clients on the web.

check it out! (esp. the 12th & 13th post...) :D
http://www.vbforums.com/showthread.php?p=2744364#post2744364

DigiRev
May 3rd, 2007, 11:49 AM
Can you use no-ip without entering your credit card details? I couldn't get it to work - luckily I was refered to www.dyndns.com, it's easy to use, free, plus I found the source code for two IP Update Clients on the web.

check it out! (esp. the 12th & 13th post...) :D
http://www.vbforums.com/showthread.php?p=2744364#post2744364

No-IP is free. I also heard dyndns is good but I've never tried it.

You might have accidentally went to where you buy a DNS name, since they sell them and also offer them for free. But their free ones don't require a credit card number or anything, just an e-mail address.