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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:20:36+00:00 2026-06-12T18:20:36+00:00

I have created a simple game, that two computer connect together. I have tested

  • 0

I have created a simple game, that two computer connect together. I have tested on same computer, no problem. When I create ad-hoc network (in Windows 7). One computer is a server, it created successfully :

ssock = new ServerSocket(PORT);
sock = ssock.accept();

And one computer is client:

sock = new Socket("localhost", PORT);

When run to this line. I received this error :

java.net.ConnectException: Connection refused: connect at
java.net.PlainSocketImpl.socketConnect(Native Method) at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at
java.net.Socket.connect(Socket.java:529) at
java.net.Socket.connect(Socket.java:478) at
java.net.Socket.(Socket.java:375) at
java.net.Socket.(Socket.java:189) at
com.controller.MainController$GameObject.(MainController.java:78)
at com.controller.MainController$3.run(MainController.java:180) at
java.lang.Thread.run(Thread.java:662)

Please help me point out, what wrong here.

Thanks 🙂

  • 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-06-12T18:20:37+00:00Added an answer on June 12, 2026 at 6:20 pm

    In the line

    sock = new Socket("localhost", PORT); 
    

    the first argument “localhost” is the hostname of the machine you want to connect to. “localhost” always means the current machine. When the server runs on another machine, you have to tell the socket where to find it.

    You need to replace “localhost” with the IP address or the hostname of the other machine. When you don’t know these, follow these steps on the server machine:

    • Start -> Run
    • enter cmd and press enter to open the command shell
    • enter ipconfig in the command shell and press enter

    You will now see configuration information about all network adapters on the machine, including their IP addresses.

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

Sidebar

Related Questions

I have created a simple test game that randomly spawns icons that move around
How to manually create Friendly URLs? (PHP) So I have created simple php file
I have plans to create a simple bot for a game I run and
I'm thinking to create a simple game that displays itself on the external monitor,
I am working on a game that will have a two dimensional board of
I have a somewhat simple game that I'm making and now that I'm testing
I am creating a simple game using Java. I have created the game's menu
I have created a simple game using Win32 and gdi. I would like to
I have two tables that pertain to this part of a trivia quiz game:
i added sprite to scene by this tutorials : http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1 but i have bad

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.