socket.io is the module for node.js, it is made by using the concept of websocket. In simple words socket.io is the way to talk from client to server and from server to client. Well there is a very popular technology in the market is called websocket which does the same work but not supported by all browsers, by default the websocket is available into html5.
Socket.io runs in all browser, so what it will do for run application in all browsers. Socket.io first makes the connection by using the websocket. If it's not supported by any browser then it uses another method for make connection. Here is the fallback transports by using socket.io
websocket,
htmlfile,
xhr-polling,(ajax long polling)
jsonp-polling
flash socket
socket.io makes the percistence connection between server and client. It shares the javascript code between server and client. when the client emit the particular messesage along with keyword on particular event, At the same time in server the function would run which is associated with the same keyword that the browser emitted. Here is the example
CLIENT
socket.emit('doSomeWork', function (){
///some work here///
});
SERVER
socket.on('doSomeWork, function (){
///some work here///
});
"doSomeWork" is the same keyword which is shared betweent the client and server.
Socket.io runs in all browser, so what it will do for run application in all browsers. Socket.io first makes the connection by using the websocket. If it's not supported by any browser then it uses another method for make connection. Here is the fallback transports by using socket.io
websocket,
htmlfile,
xhr-polling,(ajax long polling)
jsonp-polling
flash socket
socket.io makes the percistence connection between server and client. It shares the javascript code between server and client. when the client emit the particular messesage along with keyword on particular event, At the same time in server the function would run which is associated with the same keyword that the browser emitted. Here is the example
CLIENT
socket.emit('doSomeWork', function (){
///some work here///
});
SERVER
socket.on('doSomeWork, function (){
///some work here///
});
"doSomeWork" is the same keyword which is shared betweent the client and server.
No comments:
Post a Comment