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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:44:39+00:00 2026-06-14T16:44:39+00:00

I’m making simple peer to peer game and I decided to use XML to

  • 0

I’m making simple peer to peer game and I decided to use XML to send information over sockets(example below). But I’m not sure how to send it ? I should simply use ObjectOutputStream.writeObject(obj) and as parameter use object from my example ?
Mainly I’m asking, how does look proper sending XML objects over sockets.

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

public class SendIPObject {
    public static void main(String[] args) throws Exception {
        JAXBContext context = JAXBContext.newInstance(IPSender.class);

        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

        Player object = new Player();
        object.setID(0);
        object.setIP("192.167.211.167");

        m.marshal(object, System.out);

    }
}






import java.io.Serializable;

abstract public class Player implements Serializable{
    private String ip;
    private int id;

    public String getIP() {
        return ip;
    }

    public int getID() {
        return id;
    }

    public void setIP(String ip) {
        this.ip = ip;
    }

    public void setID(int id) {
        this.id = id;
    }

}
  • 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-14T16:44:40+00:00Added an answer on June 14, 2026 at 4:44 pm

    XML is sent as plain string. So first step would be to create clients that can send and receive from each other strings, e.g. “Hello, world.”. Next you need to create an object and using JAXB convert to String and send. Than receive it on other client and using JAXB again. This way you can easily debug what you send and receive. Once you’ve done it you can try to avoid converting to temporary xml string and use socket streams directly on marshalling and unmarshalling.
    I think you shouldn’t use ObjectOutputStream because it serializes object to byte array. But you need to “serialize” your object to XML (string) and send it.
    Here you can see how can you marshal object to java String: I want to convert an output stream into String object

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.