• 0

Java Socket Question


Question

Hey all,

I just did the Java KnockKnock and Datagram tutorial. When I run the server and client on my local network at home, it works just fine. When I run the server on my desktop at my univeristy and my client on my laptop at home, it no longer works.

Is there something simple I can do to fix this, or is there a simple explanation or reason as to why other pieces of software work just fine, but mine wont?

The tutorial

http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html

Thanks :D

Link to comment
https://www.neowin.net/forum/topic/1141554-java-socket-question/
Share on other sites

11 answers to this question

Recommended Posts

  • 0
  On 14/03/2013 at 04:47, thatguyandrew1992 said:

Turning off the firewall didn't help :( If the ports I try are blocked, how do other pieces of software have no issues? Is it because im connecting directly, vs going through a server?

Because the server is at your university. The network admin people at your university are blocking incoming connections. Outgoing connections are unaffected.

  • 0
  On 14/03/2013 at 04:50, rfirth said:

Because the server is at your university. The network admin people at your university are blocking incoming connections. Outgoing connections are unaffected.

Wouldn't I likely have something that has an incoming connection too? Cubby,Skydrive, video games, teamspeak etc? Why is my program different?

  • 0
  On 14/03/2013 at 04:52, thatguyandrew1992 said:

Wouldn't I likely have something that has an incoming connection too? Cubby,Skydrive, video games, teamspeak etc? Why is my program different?

Your program is a server program. It sits and waits for an incoming connection on a specific port. If your router is blocking incoming connections, it's not going to work.

Client programs initiate the connection. First they connect to the server and negotiate the connection. Then the server can send a response, and you can do whatever you want.

In short, put the server somewhere you have control. At home, you can open the required ports on your router. And keep in mind that your ISP will block certain ports like 80.

  • Like 1
  • 0
  On 14/03/2013 at 05:29, vcfan said:

no firewall

client ------------------>server : OK

with firewall blocking ports

client ------------|BLOCKED PORT| server : ERROR CANNOT CONNECT TO SERVER

^ lol, worst diagram I've seen today :D

But yeah, seems a certain someone doesn't fully grasp client/server connections...

  • 0
  On 14/03/2013 at 19:24, thatguyandrew1992 said:

I was just wondering about this issue since Cubby Direct Sync works (maybe it's transferred through their server?) and how bit torrent will work, but not this little Java program.

They both use external servers/trackers to handle things. One thing to verify though, how are you connecting? If via the global IP, then you must use port forwarding as it is connecting to the schools router which would then have to know to forward the connection onward to the specified target. If using a local ip, well unless you are on the network it won't work.

Using cubby and such would connect to cubby servers which even if you don't remain connected to it, would be able to create the connection tunnel for any other services.

This topic is now closed to further replies.