• 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

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

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

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

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

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

    • JetBrains is working to cut false positives in RustRover 2026.2 by David Uzondu Recently, JetBrains released the fifth EAP build of its dedicated IDE, RustRover 2026.2, bringing improvements like a Run gutter icon for criterion_main! macro benchmarking and a feature that alerts you when there are unused traits in your current scope. Now, the company is out with a blog post addressing one of the "most common" complaints from users: false positives. In RustRover, a false positive occurs when the editor incorrectly highlights something as an error even though the project compiles and runs successfully. This mismatch flags a gap between the IDE's internal intelligence and the actual compiler. When the editor flashes red warnings over perfectly valid code, developers lose trust in the tool, which stalls momentum. Traditionally, RustRover runs cargo check to detect compiler errors and warnings, but it also relies on its own code analysis engine to power real-time features. To provide quick feedback, this engine parses your source code into a syntax tree while inferring types and resolving names as you type. Because this engine must work on broken, half-written code and react instantly, its logic sometimes diverges from the compiler's, producing false positives that do not exist in the compiler's eyes. JetBrains said that it has a "dedicated task force" focused specifically on identifying and fixing false positives by analyzing user reports and examining large-scale open-source projects. To speed up this process, the team built an internal system modeled after Crater, the famous Rust project that compiles and runs tests for every single crate published on crates.io. This automated pipeline compares the diagnostics from RustRover's analysis with actual compiler output to catch discrepancies before they reach users, ensuring smoother workflows. RustRover, for those who're unaware, is a dedicated IDE designed specifically for Rust developers. It's been around for a couple of years now, providing features like built-in debugging via LLDB, seamless cargo integration, advanced macro expansion, and HTML support. JetBrains distributes the app under two licensing models: a paid commercial subscription and a free option for non-commercial use.
    • Last year I bought the 2TB variant for $114 on Amazon. That's crazy that the 1TB is now 67% more expensive for half the storage, even with the newer T9 already on the market. And that's considered a good deal.
    • You can disable all non needed features from Brave. There is also Brave Origin which removes them entirely and it is free for Linux.
    • I wish I could use Brave but the tab suspension feature is horrible. It doesn't suspend them like Edge does. Even after 2h open with 70+ tabs (same as Edge), it has 2GB more consumption than Edge for no reason.
    • TeamViewer 15.78.4.0 by Razvan Serea TeamViewer is the fast, simple and friendly solution for remote access over the Internet - all applications in one single, very affordable module. Remote control of computers over the Internet, Instantly take control over a computer anywhere on the Internet, even through firewalls. No installation required, just use it fast and secure. Training, sales and teamwork, TeamViewer can also be used to present your desktop to a partner on the Internet. Show and share your software, PowerPoint presentations etc. File transfer, chat and more, Share your files, chat, switch the direction during a teamwork session, and a lot more is included in TeamViewer. TeamViewer key features: Cross-platform remote access (Windows, macOS, Linux, Android, iOS, IoT) Attended and unattended remote control Secure file transfer between devices Remote printing to local printers Multi-monitor support with easy switching Wake-on-LAN for sleeping devices Session links for quick connections (no password sharing) Web client access (no installation needed) End-to-end encryption (AES-256) Two-factor authentication and access controls AI-powered session insights and reporting Mass deployment and device management tools Customizable allow/block lists for security Command line and script execution remotely Performance monitoring and analytics dashboards TeamViewer 15.78.4.0 changelog: Improvements Permissions inheritance has been improved, increasing reliability when permissions are assigned to user group managers. Bugfixes Fixed a bug where 'Show details' button was not showing up on command bar upon selection of a device group. Fixed a bug which was causing the legacy groups to disappear when applying hide offline filter in basic view. Fixed a bug where devices were loading infinitely after login. Fixed a bug which was causing crash in application. Download: TeamViewer 15.78.4.0 | 32-bit | Portable | Mac | ~70.0 MB (Free for personal use) View: TeamViewer Home Page | Release Notes | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Year In
      Primer1st earned a badge
      One Year In
    • Experienced
      JayZJay went up a rank
      Experienced
    • Reacting Well
      Sir_Timbit earned a badge
      Reacting Well
    • Week One Done
      rubentuben8 earned a badge
      Week One Done
    • Week One Done
      ARaclen earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      517
    2. 2
      PsYcHoKiLLa
      229
    3. 3
      Edouard
      135
    4. 4
      ATLien_0
      87
    5. 5
      Steven P.
      82
  • Tell a friend

    Love Neowin? Tell a friend!