10

Based from the official site of socket.io http://socket.io/#how-to-use, I can't find any terminologies. What are the differences between socket.emit , socket.on , and socket.send ? Can't find articles which differentiate between these things. I am currently developing a real-time application.

GadaaDhaariGeek
  • 971
  • 1
  • 14
  • 33
Orvyl
  • 2,635
  • 6
  • 31
  • 47
  • hello @Orvyl i want this question more , like socket.broadcast, socket.join , socket.in .... please – Rajanboy Feb 06 '22 at 15:37

2 Answers2

16

socket.emit - This method is responsible for sending messages. socket.on - This method is responsible for listening for incoming messages. socket.end - This is the first time I'm hearing such a method. I am not really sure that it exists.

DifferentPseudonym
  • 1,004
  • 1
  • 12
  • 28
Sergey Rura
  • 234
  • 2
  • 3
  • 1
    Socket.send should be seen as a low-level api (for custom protocols development, or cases where maximum messages per second speed is crucial), and Socket.emit a higher-level interface (for app development). – Sergey Rura May 18 '13 at 09:39
  • What is Socket.join() – Ayush Kumar Jun 04 '22 at 14:10
1
  • socket.emit Creates events to send data
  • socket.on listens for specific events to collect data
  • socket.send Sends events of the name message
Jake
  • 97
  • 1
  • 9