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

  • Home
  • SEARCH
  • 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 6247913
In Process

The Archive Base Latest Questions

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

I have a java-based server that allows client applications to connect via other programming

  • 0

I have a java-based server that allows client applications to connect via other programming languages (java, unity, obj-c). I would like to know how to add javascript to this list using node.js and socket.io. The server listens on a set port and accepts simple json data plus an int for length in bytes, it response in the same format. The format of the “packet” is like so:

first four bytes are the length
00 00 00 1c

remaining bytes are the data
7b 22 69 64 22 3a 31 2c 22 6e 61 6d 65 22 3a 22 73 6f 6d 65 77 69 64 67 65 74 22 7d

The data is sent over TCP and is encoded in little endian. The object in originating from Java is modeled like so:

public class Widget {
    private int id;
    private String name;
    public int getId() { return id; }
    public String getName() { return name; }
}

The JSON would be:

{"id":1,"name":"somewidget"}
  • 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-24T12:57:44+00:00Added an answer on May 24, 2026 at 12:57 pm

    So if you want just send request to server and get response you could do this:

    var net = require('net');
    
    var soc = net.Socket();
    soc.connect(8088);
    
    soc.on('connect', function(){
      var data, request, header;
    
      data = {request : true};
      data = JSON.stringify(data);
    
      request = new Buffer(Buffer.byteLength(data));
      request.write(data);
    
      header = new Buffer(4);
      header.write(request.length.toString());
    
    
      // send request  
      soc.end(header.toString('binary') + request.toString('binary'));
    });
    
    soc.on('data', function(buffer){
      // Crop length bytes
      var data = JSON.parse(buffer.slice(4).toString('utf-8'));
      soc.destroy();
    
      console.log(data);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to profile a server-client Java application (based on Jersey/REST FYI). I have
I have to choose a technology to connect my Application/Presentation Layer (Java Based) with
I have Java and Flash client applications. What is the best way for the
I have a Java application with server and Swing client. Now I need to
I have an old memcached client implementation that is based of the danga client,
i have a java based desktop app that i am hoping to rewrite as
I have a Java program that creates a server socket and accepts connections from
I'm looking to write a small client-server-based text game that handles multiple client connections
I have a java based application that manipulates a mysql database. I would like
I have limited knowledge of Java-based technologies, and for business enforced reasons, I may

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.