0

I am using Socket.io in a nodejs app-

I am storing the socket.id when I receive a connection. However, I need to have the socket object whose id, is the one I stored. How can I get a Socket object having just the id?

Thanks so much!

  • Can you provide us with a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) or some demo code so we can see what you have tried? – mnestorov Oct 15 '19 at 06:55
  • Possible duplicate of [Socket.IO 1.0.x: Get socket by id](https://stackoverflow.com/questions/27055989/socket-io-1-0-x-get-socket-by-id) – mnestorov Oct 15 '19 at 07:05
  • simply use this : io.sockets.connected[socket.id] – Nasr Oct 15 '19 at 12:29
  • Thanks to both of you: io.sockets.connected[socket.id] did the trick. It was a dumb question, sorry but I am very new to socket.io – user5225005 Oct 16 '19 at 04:46

0 Answers0