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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:04:45+00:00 2026-06-02T03:04:45+00:00

I have been searching for this particular problem for the past week, and since

  • 0

I have been searching for this particular problem for the past week, and since I couldn’t find any information on the subject(that wasnt outdated), I just decided to work on other things. But now I am at the point where I need to be able to send data(that I constructed) to specific clients using their ID who are connected to my server using node.js and socket.io. I already store the ID in an object for each new connection. What I need to know is a way to just send it to a connection ID I choose.

Something like: function send(data, client.id) {};

I am using an http server, not TCP.

Is this possible?

edit:

server = http_socket.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.end(respcont);
    client_ip_address = req.header('x-forwarded-for');
    });
socket = io.listen(1337);   // listen
//=============================================
//  Socket event loop
//=============================================
socket.on ('connection', function (client_connect) {
    var client_info = new client_connection_info();     // this just holds information 
    client_info.addNode(client_connect.id, client_connect.remoteAddress, 1); // 1 = trying to connet

    var a = client_info.getNode(client_connect.id,null,null).socket_id; // an object holding the information.  this function just gets the socket_id
    client_connect.socket(a).emit('message', 'hi');

    client_connect.on('message', function (data) {
         });
    client_connect.on ('disconnect', function () {

    );
});

solution: I figured it out by just experimenting… What you have todo is make sure you store the SOCKET, not the socket.id (like i was doing) and use that instead.

client_info.addNode(client_connect.id, client_connect.remoteAddress, client_connect, 1)

var a = client_info.getNode(client_connect.id,null,null,null).socket;
    a.emit('message', 'hi');
  • 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-02T03:04:46+00:00Added an answer on June 2, 2026 at 3:04 am

    If you need to do this, the easiest thing to do is to build and maintain a global associative array that maps ids to connections: you can then look up the appropriate connection whenever you need and just use the regular send functions. You’ll need some logic to remove connections from the array, but that shouldn’t be too painful.

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

Sidebar

Related Questions

I have been searching for this solution for some time have not found any
I have been searching this for quite sometime but could not find an appropriate
I have been searching about this subject now for quite a few days. And
I have been searching for an answer to this but can't find it on
I have been searching the internet wildly for an answer to this question. We
I have been searching everywhere but I could not find an answer. I need
I have been searching around using Google but I can't find an answer to
I have been searching for the past through days, trying to figure out how
I have been searching but unable to find a proper list. Can someone please
I have been having trouble searching through a MySQL table, trying to find entries

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.