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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:41:43+00:00 2026-06-12T00:41:43+00:00

io.sockets.on(‘connection’, function(socket){ socket.on(‘customevent’, function(){…}) …}) io.sockets.on simplified logic: each socket will respond to an

  • 0
io.sockets.on('connection', function(socket){  
    socket.on('customevent', function(){...})   
...})

io.sockets.on simplified logic: each socket will respond to an event ('connection' by default);
socket.on simplified logic: each socket will respond to an event only if connection is established (only when 'connection' event is received);

So, what is the logic here? Is io.sockets.on function used only for establishing connection like a simple callback?
I see that both functions stand for ‘each socket responds’ and there is no need in socket.on because io.sockets.on will respond to all events as well as socket.on‘s given socket.

Could someone explain me?

  • 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-12T00:41:44+00:00Added an answer on June 12, 2026 at 12:41 am

    It’s possible for different socket connections to handle different events differently, depending on their nature. io.sockets.on(...) specifies common behavior for all socket connections (i.e. behavior that doesn’t depend on the identity of the connection); socket.on(...) (where socket represents a particular connection) specifies behavior specific to that connection.

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

Sidebar

Related Questions

io.sockets.on('connection', function (socket) { socket.on('requestGame', function (data) { for (var game in games) if
nodeJS: io.sockets.on(connection,function(client) { client.emit('Value',{Data:'a string'}); }); C#: socket.On(Value, (data) => { PlainString PS =
i am using raw sockets to create my own socket. i need to set
Using flash sockets in my irc client, can I serve the socket policy file
Using sockets in C, is it safe to do this in a function? int
Blocking berkeley sockets normally used by Ruby has one downside: if connection with remote
I'm working with asyn sockets now. I have a callback function 'onDataReceived', which is
I have created four sockets with different port configurations. With the select function I
I plan to use sockets to make function calls between a client 32 bit
I was playing with sockets on local machine with no network connection. See below:

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.