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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:37:37+00:00 2026-05-29T21:37:37+00:00

I have a written a simple Client-Server pair, sending an Object to the server.

  • 0

I have a written a simple Client-Server pair, sending an Object to the server. I have tested the code and it works, provided I use LOCALHOST as the server name.

When attempting to connect to the server using my own IP address, the client continuously times out. I cannot help thinking I’ve missed a trick, if someone could take a look at the code I would be very grateful. Many Thanks, J.

client

ObjectOutputStream oos = null;
  ObjectInputStream ois = null;
  Socket socket = null;
  Person p = null;

  try {
    // My IP address entered here..
    socket = new Socket("xx.xx.xxx.xxx", 3000);
    // open I/O streams for objects
    oos = new ObjectOutputStream(socket.getOutputStream());
    ois = new ObjectInputStream(socket.getInputStream());


    /*
    // read an object from the server
    p = (Person) ois.readObject();
    System.out.print("Name is: " + p.getName());
    oos.close();
    ois.close();*/

    //write object to the server
   // p = new Person("HAL");
    oos.writeObject(new Person("HAL"));
    oos.flush();
    ois.close();
    oos.close();

  } catch(Exception e) {
    System.out.println(e.getMessage());
  }

Server

public Server() throws Exception {
 server = new ServerSocket(3000);
 System.out.println("Server listening on port 3000.");
 this.start();

}

  • 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-29T21:37:38+00:00Added an answer on May 29, 2026 at 9:37 pm

    You either need to make your server bind to 0.0.0.0 (wildcard, all interfaces on your machine) or the specific IP you want it to listen on. The ServerSocket constructor you’re using only takes a port number and binds to localhost which is going to resolve to 127.0.0.1

    server = new ServerSocket(3000, 5, InetAddress.getByName("0.0.0.0"));
    

    Edit to add: The second paramater is the backlog size. This is the number of connections that can be queued waiting for you to accept() them before additional connection attempts will result in “connection refused”.

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

Sidebar

Related Questions

I have a very simple client server code written java(server listens on some port
i have written simple client server socket programming code as follow MyServer.java import java.io.DataInputStream;
I have a simple UDP client server written in C++ on Ubuntu 9.10 where
I have written a simple server - client program with Swing interface using singleton
I have written a simple TCP client and server. The problem lies with the
I have written a simple client server program in C under linux. I have
I have a very simple server written in C and an equally simple client
I have written a simple single threaded client server application in Visual C++ .
I have written a simple WCF service that accepts and stores messages. It works
In sockets I have written the client server program. First I tried to send

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.