Results 1 to 7 of 7

Thread: Chat program

  1. #1

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Chat program

    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.
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Chat program

    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...

  3. #3

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Chat program

    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"?
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  4. #4

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Chat program

    woops just realised i was calling it port forwarding... i meant port redirecting!
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  5. #5
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Chat program

    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.

  6. #6
    Lively Member xera's Avatar
    Join Date
    Nov 2006
    Location
    SA
    Posts
    104

    Re: Chat program

    Quote Originally Posted by DigiRev
    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...)
    http://www.vbforums.com/showthread.p...64#post2744364
    Did you know... ..that you live in a Universe?!
    Code:
    var Answer = Uni + Verse = single + spoken + sentence;


    Life is amusing...

  7. #7
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Chat program

    Quote Originally Posted by xera
    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...)
    http://www.vbforums.com/showthread.p...64#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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width