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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:58:46+00:00 2026-05-30T12:58:46+00:00

I am new to Node and Redis, so forgive me if I’m missing something

  • 0

I am new to Node and Redis, so forgive me if I’m missing something crucial here. I am trying to store a Node.js net.Socket object in Redis, using the node_redis client, so I could reuse a connection made previously on this Socket.
I am storing the socket as a Value as a part of a “users” set:

client.sadd("users", username); //username is a string
client.hmset(username, "ip", socket.remoteAddress, "connection", net.Socket(socket));

At a different point, I am retrieving this socket as:

    client.smembers("users", function(err, replies) {

            replies.forEach(function(reply,i){
            if(recipient == reply) {       //recipient is the username i've got

                    client.hget(reply, "connection", function(err, obj) {
                    console.log("socket's remoteaddress = " +  net.Socket(obj).remoteAddress);
        net.Socket(obj).write("asdasdasd");
            });

            }
    });
    });

But, the:
net.Socket(obj).remoteAddress); is logged as ‘undefined’.
Also,
net.Socket(obj).write(“asdasdasd”); gives me and error saying:

Error: This socket is closed.

So I guess my question is – can you store Sockets this way in Redis and expect them to work upon retrieval? Is there a correct / better way to do this?

P.S. I tried retrieving the Socket without the cast to net.Socket and it still didn’t do any good.

  • 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-30T12:58:47+00:00Added an answer on May 30, 2026 at 12:58 pm

    Sockets and socket APIs (such as Berkeley Sockets) intrinsically handle special system-specific resources for which it just wouldn’t make any sense to store or reference on a remote system, or even serialize for that matter.

    Although, in reality, sockets are often uniquely identified by file descriptors so you could easily store that small, unique integer in a database for later access; however, that integer would only be meaningful during the active lifetime of that socket within that process instance. A strategy such as this one will be fraught with challenges, mainly having to do with the transient nature of the socket file descriptor number.

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

Sidebar

Related Questions

I'm using socket.io and Redis together with node.js - code below. I'm definitely being
I'm trying to add a new node to an jQuery SimpleTree , but all
I am using redis and node (with node_redis ) and I would like to
I'm trying to make a simple custom field field_book_year for the new node type
I am trying to create a new node type like this: http://www.live-wtr.ru/leo/Tikz9.png but don't
I am trying to create a new node that is a child of an
I am trying to programmatically add a new XLink node to an XDocument but
I'm pretty new with C# and .NET. I'm trying to model a graph with
I am using the following function to insert a new node into a sorted
Using Drupal 6. I've created a new node type with CCK, which has one

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.