Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6344805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:42:43+00:00 2026-05-24T20:42:43+00:00

I’m making a client/server pair with sockets to send and receive data back and

  • 0

I’m making a client/server pair with sockets to send and receive data back and forth. When I’m at home on my internet using two separate machines for client/server, it works fine as expected. Data is transmitted and so forth.

However, today when I was working at a local coffee shop (Second Cup, in case that’s relevant), this did not work. I kept getting the following errors: either connection timed out, or no route to host.

Here is the relevant code:

Server:

public class TestServer {

public static void main(String[] args) throws Exception {

    TestServer myServer = new TestServer(); 
    myServer.run(); 

}

private void run() throws Exception {

    ServerSocket mySS = new ServerSocket(9999);     

    while(true) {

        Socket SS_accept = mySS.accept(); 

        BufferedReader myBR = new BufferedReader(new InputStreamReader(SS_accept.getInputStream()));

        String temp = myBR.readLine(); 
        System.out.println(temp); 

        if (temp!=null) {

            PrintStream serverPS = new PrintStream(SS_accept.getOutputStream()); 
            serverPS.println("Response received"); 

        }

    }
}

}

Client: (the relevant part)

//sends a command to the server, and returns the server's response
private String tellServer(String text) throws Exception {

    mySocket = new Socket("192.168.0.XXX", 9999); //the IPv4 address      

    //use the socket's outputStream to tell stuff to the server 
    PrintStream myPS = new PrintStream(mySocket.getOutputStream()); 
    myPS.println(text); 

    //the following code will get data back from the server
    BufferedReader clientBR = new BufferedReader(new InputStreamReader(mySocket.getInputStream())); 
    String temp = clientBR.readLine(); 

    if (temp!=null) {
        return temp; 
    } else {
        return ""; 
    }

}

It’s pretty much as simple as can be. Again, as mentioned, at home on my internet it works fine – just do ipconfig, grab the IPv4 address, and put it in for the client. In coffee shops with free wifi, it doesn’t work. I even fiddled with many different ports just in case.

Thanks for any help, I’m new to sockets and finding this confusing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:42:44+00:00Added an answer on May 24, 2026 at 8:42 pm

    192.168.x.y is a local address. source

    You need your home machines ip address as the INTERNET sees it.

    When you’re home next, go to http://www.whatismyip.com/ and see what it thinks you are.

    Note that you might need to go onto your router and route traffic from your router to your machine for port 9999, since that’s what you’ll probably be hitting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I want to construct a data frame in an Rcpp function, but when I
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.