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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:11:16+00:00 2026-05-27T19:11:16+00:00

I recently started learning networking with sockets in java. So i’ve created a multiplayer

  • 0

I recently started learning networking with sockets in java. So i’ve created a multiplayer game that is playable on the same computer but i wanted to make it network-multiplayer, then i learned about sockets, now, i want to send the variables of the position of the player in the game to a server which then can place that player in that position in the other game instance running on a different machine. And the thing is, i just fail at it and all the data doesnt get received or read. I also want the position to get sent and received constantly which is also a problem for me…

I tried using ObjectOutputStream and ObjectInputStream to send a int array with the variables but that also failed, so could you please show me how to do this, because i have no idea and i cant seem to find an answer online.

Thx

  • 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-27T19:11:16+00:00Added an answer on May 27, 2026 at 7:11 pm

    As the easiest solution, use the Object Streams to send an object created by you where you store these coordinates, but this class must implement Serializable interface. For example for 2d coordinates:

    class Coords implements Serializable {
        int x, y;
        public Coords(int x, int y) {
            this.x = x;
            this.y = y;
        }       
    }
    
    ...
    
    // To write:
    // oos = ObjectOutputStream of the socket
    Coords tmp = new Coords(x, y);
    oos.writeObject(tmp);
    oos.flush();
    
    ...
    
    //To read:
    //ois = ObjectInputStream of the socket
    Coords tmp = (Coords)ois.readObject();
    

    http://java.sun.com/developer/technicalArticles/ALT/sockets/ can also aid you.

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

Sidebar

Related Questions

I recently started learning Java and found it very strange that every Java public
I've recently started learning Scala and was disappointed (but not surprised) that their generics
I recently started learning Java and i came across a statement including (ActionEvent e
I have recently started learning C++, but I require a compiler. I have tried
I just recently started learning RoR and found that Prototype.js is a default javascript
When i started learning android i learned that R.java files goes to /gen folder
I've recently been learning python and I just started playing with networking using python's
I recently started learning ruby, and I understood that you coud use code blocks
I have recently started learning java as my first ever step into object oriented
I've recently started learning HLSL after deciding that I wanted better lighting than what

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.