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 6137415
In Process

The Archive Base Latest Questions

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

I am fairly new to java and I am currently experimenting with sockets and

  • 0

I am fairly new to java and I am currently experimenting with sockets and buffers.

What I wanted to try was just to instantiate a connection from one local java app and another. I am using ServerSocket and Socket.

The server app has a thread that listens for connections:

    public void run() {

    try{

        ServerSocket serverSock = new ServerSocket(62666);

        while(doRun){

            Socket sock = serverSock.accept();
            BufferedReader reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));

            InfoReader.gui.writeToTextArea(reader.readLine() + "\n");



            reader.close();

        }
    }catch(IOException e){
        e.printStackTrace();
    }

}

The “client” simply sends a string to the server (well it should, but I can’t make it work):

try{
        Socket sock = new Socket("127.0.0.1",62666); 
        PrintWriter writer = new PrintWriter(sock.getOutputStream());
        writer.print("Connection works!");
    }catch(IOException e){
        e.printStackTrace();
    }

I am sure that the port is open and forwarded to the local machine already. I’ve checked on http://canyouseeme.org/.

I’ve also tried using my external IP address as the IP of the socket in the client. It did not work either.

Any help appreciated :).

Mike.

  • 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-23T17:43:25+00:00Added an answer on May 23, 2026 at 5:43 pm

    Ok, then as an answer so you can close the question 😉

    Add a flush() and a close() to the Writer.

    Hope that helps. 🙂

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

Sidebar

Related Questions

I am fairly new to Objective-C. Currently porting my own library from C#/Java to
I'm fairly new to Rational Functional Tester (Java) but I have one large blank.
I'm still fairly new to Python, and my OO experience comes from Java. So
I'm fairly new to Java. Currently trying to have the filename given in args[]
I'm fairly new to SQL and I'm currently reworking a java program that another
Another question about my implementation. I am fairly new to java/android coming from a
I'm fairly new to Android/Java and wanted to make an app that displays info
Im fairly new to Java and im just looking for a little help Im
I'm fairly new to Java (been writing other stuff for many years) and unless
I'm fairly new to Java and am writing an app that needs an XML

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.