Giter VIP home page Giter VIP logo

Comments (6)

reqshark avatar reqshark commented on August 27, 2024

hi @GrimDev, sndtimeo and rcvtimeo aren't going to emit either of those events.

All they are designed to do is delay send or recv operations on the socket.

Can you paste your code so we can take a look?

from node-nanomsg.

GrimDev avatar GrimDev commented on August 27, 2024

Thanx for your quick reply.

See my code bellow (coffee script)

// I create my socket in pair
console.log "init"
@socket = nano.socket("pair")
addr = "tcp://0.0.0.0:1665"
sock = @socket.bind addr

// Set snttimeo and rcvtimeo at 100
@socket.sndtimeo(100)
@socket.rcvtimeo(100)

// I do a ping each 30 sec
ping = =>
version = @protocolVersion
msgType = 20
message = 0
phone = 0
message = [version,msgType,message,param].join ":"
@socket.send message

setInterval ping, 30000

// Now I want to execute function when timeout occurs
@socket.on "I dont know what I can put here" , -> #my function

I tryed socket.on "error", "timeout", "survey-timeout", but didnt work.

from node-nanomsg.

reqshark avatar reqshark commented on August 27, 2024

Oh I'm sorry I can't understand coffee, can u please translate into JS!

Sent from my iPhone

On Mar 25, 2015, at 9:01 AM, GrimDev [email protected] wrote:

Thanx for your quick reply.

See my code bellow (coffee script)

I create my socket in pair

console.log "init"
@socket = nano.socket("pair")
addr = "tcp://0.0.0.0:1665"
sock = @socket.bind addr

Set snttimeo and rcvtimeo at 100

@socket.sndtimeo(100)
@socket.rcvtimeo(100)

I do a ping each 30 sec

ping = =>
version = @protocolVersion
msgType = 20
message = 0
phone = 0
message = [version,msgType,message,param].join ":"
@socket.send message

setInterval ping, 30000

Now I want to execute function when timeout occurs

@socket.on "I dont know what I can put here" , -> #my function

I tryed socket.on "error", "timeout", "survey-timeout", but didnt work.


Reply to this email directly or view it on GitHub.

from node-nanomsg.

GrimDev avatar GrimDev commented on August 27, 2024

Yes.

This is the translation

// Init socket
var addr, ping, sock, socket;
socket = nano.socket("pair");
addr = "tcp://0.0.0.0:1665";
sock = this.socket.bind(addr);

// Params
this.socket.sndtimeo(100);
this.socket.rcvtimeo(100);

// Ping function
ping = function() {
var message, msgType, phone, version;
version = _this.protocolVersion;
msgType = 20;
message = 0;
phone = 0;
message = [version, msgType, message, param].join(":");
return _this.socket.send(message);
}
setInterval(ping, 30000);

// Catch timeout
socket.on("timeout", function() {
console.log("Timeout catched !");
})

from node-nanomsg.

reqshark avatar reqshark commented on August 27, 2024

Timeout has a special meaning in JS that doesn't apply here.

maybe we should think about changing the language in the docs to "delay" to avoid that confusion in the future.

There's no timeout event that will fire here, it's just setting a silent delay on the socket I/O operation.

from node-nanomsg.

GrimDev avatar GrimDev commented on August 27, 2024

OK

I understood rcvtimeo and sndtimeo was the delay timeout, but I thought a timeout event is throw when it occurs.

I'll do a ping/pong to detect deconnections.

Thx for your replies.

from node-nanomsg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.