Jump to content
  • Advertisement
Sign in to follow this  
JinJo

[java] cant connect to my server (client /server)

This topic is 4233 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have written a small java app for server and aplet for client for a simple chat program. (for learning network programming). Now they both worked and i tested it with my client connecting to local host. Now i am wanting to test from another pc somewhere over internet. I went to a site to get my actual ip, say 85.43 etc. So I tell the client to connect to that, and no mater what port I use, say 7654, the client can never connect. After a few days of going mad with this (i am behind a router but port 7654 and loads more are open and i have no firewall) I thought maybe it is the browser that the applet is in? my server basically does thi ... try { servSock = new ServerSocket(7654); } .... and my client does this .... theHost = "85.49.72.120"; (for example) thePort = 7654; try { sock = new Socket(theHost, thePort); .... I think it's the client that is wrong here. i think i might need to get the applet to have params passed in from browser but I dont know what these are can anyone help. This is me learning network code as I am doing a multiplayer game for a uni project and its to be finished by next week. thanks.

Share this post


Link to post
Share on other sites
Advertisement
To ensure that it is your client application, on the client machine, open a command window and try to telnet to the server machine on the specified port. If you can connect via telnet, then it is indeed your client application. If you cannot connect, then it may be the routing to the server, an unknown firewall (or proxy server) in between, or something with your server application.

Share this post


Link to post
Share on other sites
well i just got my ip address off the myip site and then tried to telnet that address with a number of different ports.

80 does not work, all the ones i set on the router dont either. I was thinking that my app might need to set socket permissions but then telnet should still connect.

Could this be anything wrong with my computer? I reckon its the router but my mates adament he set it right?

Share this post


Link to post
Share on other sites
if your router is configured to run as a NAT (most are by default) you'll have to setup a port forward so the router sends all traffic on that port to your pc.

alternatively, you could add your pc to the DMZ group of your router and all unrecognized traffic will automatically be sent to that pc

Share this post


Link to post
Share on other sites
Quote:
Original post by JinJo

...

This is me learning network code as I am doing a multiplayer game for a uni project and its to be finished by next week.

thanks.


Ok... not that much time.


Anyway, you could run your server locally and then have your client connect to localhost or 127.0.0.1. If that works you can deduce that it's a NAT/router problem, if not there is something wrong with your code.

Lizard

Share this post


Link to post
Share on other sites
it works perfectly ok when connecting with localhost as the host input.

sorry for mispelling etc ive been out to forget about this problem lol.

i have put my ip in the dmz and a ste says it can see my port 7654 and my server says somethin connects but i still cant let someone conect over a different pc, i dunno what im doin wrong.

thanks

Share this post


Link to post
Share on other sites
Applets live in a security sandbox. One of the restrictions is that they can only connect to a server on the machine from which they were served. That's why the connection works locally for you. If you could run your server from the same IP as the web server that serves the applet, then it would work. IIRC, signed applets can bypass this restriction.

Standalone apps don't have this restriction. If you can't host your server from the same IP as the web server, I suggest you rework your applet so that it can also function as a standalone app (if you aren't sure how to do this, you should be able to find some info on Google). This will allow you to test everything on remote machines as a standalone app until you are able to host the server properly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!