• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

Chat program wont work through my router (NAT)

OK, i am building a direct chat program (use ip to connect) and i cant get it to work on my comp, most likely because of my router and NAT.

I am using TClientSocket, and TServerSocket.  I can connect to myself (127.0.0.1), but when someone trys to connect to me it gets an asynchronous socket error or something like that and it wont  connect, but i can connect to them.  I have an assigned ip address by my router 192.168.2.34, then a WAN IP from the DSL, i have tried the external ip but it just wont work.  Is there any way to get around this, shouild i use a different component, or what??  Bah, i just want it to work.
0
Joshjje
Asked:
Joshjje
  • 5
  • 4
  • 2
1 Solution
 
loop_untilCommented:
Well, does your router block the port you used for your chat program? Most routers only forward common ports (80, 21, 25 and so). You might want to check your router's configuration to make sure it is okay.

The others will have to connect using your external address (other than 192.168.x.x).

The problem does not come from the component (at the first sight) nor your program. If it works with your localhost (127.0.0.1) we might be able to make it worked with other people.

If you need more help, please provide port used, router's brand, firewall...


Hope it helps.
Have a nice day! :)
0
 
JoshjjeAuthor Commented:
I have a Belkin 4-port switch dsl/cable router.  I want to know if there is a way to have it work without having to configure the router to accept the ports, etc.
0
 
loop_untilCommented:
Well, if you make your program talk over a common port, that could do. It is not necessarily recommended but you might want to check if that's your problem. Use port 80 or something like that and you'll be set.

Port 80 is the port used for http protocol (web browsing). It means it will use this "channel" to communicate. If you are browsing here it means your router let it pass ;-).

Anyhow, tell me if it works.
See ya! :-)


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JoshjjeAuthor Commented:
Hmm i tried port 80, it still works connecting to 127.0.0.1, but still doesnt work connecting to my external ip address, however, it doesnt give the asynchronous socket error thing as it did before, it just says connecting really fast then disconnects.  Ill see if my friend can connect to my external ip but if i cant he probably cant.
0
 
ErdrickCommented:
1. Connect to http://192.168.2.34
2. Authenticate
3. go into port forwarding
4. choose a port range that reflects
   what you choose to be the port for
   your TServerSocketcomponent.
Port forwarding should look something similar to this:
       _____ ~ _____   ____________

Lets say you specified 6125 as your server port num, and the computer that will be running the program your made is 192.168.2.37

(note: this ip is what you will find if you go into dos  and type ipconfig /all on the computer that will be running your program, and is not to be confused with 127.0.0.1 which is each computers loop back address)  

your configuration for port forwarding would look like this:
       6125 ~ 6125   192.168.2.37

this would tell the router that all incoming connections to your real ip (external ip) would be sent through the router and come to 192.168.2.37, which would be your computer that is acting as the server.


I wrote a chat client awhile back and had the same problem with the asynchronous socket error message, this was caused when you have a port specified in your TServerSocket component that is already opened by another program on your system.  If this did not solve your questions or if you have any other questions lemme know.
0
 
JoshjjeAuthor Commented:
Alright, you gonna have to explain how to code this one.  How do you authenticate and go into port forwarding?  Right now all i do is set the remotehost, port, etc., then do TClientSocket.Open;  I dont see anywhere about authenticating or port forwarding.  I havent done much with these components as you can tell.  Maybe you can send me your source for the chat program you made, or just explain it here, thanks.
0
 
ErdrickCommented:
lol, i'm sorry... I didn't explain well enough I guess.  That stuff doesn't have to do with your actually coding, you actually point your webbrowser there and you should be able to change your routers settings.  As far as I know your code is probably all correct as long as your port is the same as the one your forward in the router configuration.  First, just try going to http://192.168.2.34 and see what occurs.

if you have aim my screen name is Erdrick444 msg me if you want me to walk u through it.
0
 
ErdrickCommented:
lol, i'm sorry... I didn't explain well enough I guess.  That stuff doesn't have to do with your actually coding, you actually point your webbrowser there and you should be able to change your routers settings.  As far as I know your code is probably all correct as long as your port is the same as the one your forward in the router configuration.  First, just try going to http://192.168.2.34 and see what occurs.

if you have aim my screen name is Erdrick444 msg me if you want me to walk u through it.
0
 
JoshjjeAuthor Commented:
Yeah, i can configure my router so that it will work, but i was wondering if there is some way to get around this without having to configure the router, but i guess there isnt
0
 
ErdrickCommented:
You can configure your computer to be a router if you have 2 network cards, or just directly connect your computer to the internet wan.  Other than that your going to have to tell the router where people who connect to it need to be sent, which is what it does when you forward data ports.
0
 
JoshjjeAuthor Commented:
Yeah, well i dont see any way around this so ill just give you the points and call it good, thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now