node.js - Setting up a Stateless connection with NodeJS and Socket.IO -


after prototyping project using php , unity3d i've decided on building production version using cordova , nodejs.

i'm using socket.io nodejs , having confusion connections. way had expected work out following procedure:

  1. the client connect server request
  2. the server respond request
  3. the connection closed

however, seems connection likes stay open, , if connection closed, continuously attempts reconnect not looking for. i'm attempting establish single state of data transfer, similar happens when make web-request php file.

the source code of project pretty boilerplate code:

var application = require('express')(); var http = require('http').server(application); var server = require('socket.io')(http);  http.listen(8080, function() {     console.log('listening on *:8080'); });  server.on('connection', function(socket) {     console.log('server: new connection has been received.');     server.on('disconnect', function() {         console.log('server: connection has been closed.');     }); }); 

i not need persistent connection, nor want one.

thoughts: send close handshake client. example:

  1. send data server
  2. recieve data server
  3. send close request server / close socket
  4. continue application logic once socket closed

would proper way handle this? question arises, if data gets lost, there's permanently open socket. implementing basic timeout ideal in situation? (ie: if response isn't received within 10 seconds, there error or server not available).

then socket.io wrong tool scenario. socket.io needs keep socket open events server client (and vice-versa). matter of fact, of server not support websockets, socket.io resort other mechanisms, such polling.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -