Comments (6)
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.
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.
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 addrSet 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 messagesetInterval 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.
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.
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.
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)
- add support for nng HOT 4
- Error handling HOT 3
- TypeError: Path must be a string. Received undefined HOT 2
- rfc links
- Compile error in Node V12.* HOT 6
- vulnerable dependencies HOT 1
- deprecation warning from Nan::Callback::call HOT 2
- DeprecationWarning: Buffer HOT 2
- remove package-lock.json from .gitignore HOT 2
- fallthrough warnings in nanomsg HOT 1
- are we handling scopes correctly? HOT 1
- How do i catch timeout on reqrep?
- Carsh When msg send 10K per second HOT 2
- Electron compatibility: "Loading non-context-aware native module in renderer" HOT 1
- node 14.15 compatability HOT 1
- (node:660) electron: The default of contextIsolation is deprecated and will be c hanging from false to true in a future release of Electron. HOT 2
- Double handle scope
- -Wcast-function-type in nodejs/src/node.h
- sub: filter by binary chan prefix? HOT 1
- npm install --use_system_libnanomsg=true fails
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-nanomsg.