diff options
Diffstat (limited to 'Ivy.pm')
-rw-r--r-- | Ivy.pm | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -212,6 +212,18 @@ use constant CALL_BY_REF => 1; use constant BIND_ONCE => 2; use constant MAX_TIMOUT => 1000; + +# TCP_NODELAY is for a specific purpose; to disable the Nagle buffering +# algorithm. It should only be set for applications that send frequent +# small bursts of information without getting an immediate response, +# where timely delivery of data is required (the canonical example is +# mouse movements). +use constant TCP_NO_DELAY_ACTIVATED => 1; + + +# Since Ivy is most of the time used to send events, we will priviligiate +# lag over throughtput, so _TCP_NO_DELAY_ACTIVATED is set to 1 +use constant MAX_TIMOUT => 1000; # pour pouvoir employer les regexps perl. Attention lors de l'utilisation # ne pas mettre un \n dans une chaine entre "" car l'\n sera interprete. use constant REG_PERLISSISME => ('w' => '[a-zA-Z0-9_]', @@ -1400,6 +1412,8 @@ sub _getBonjour ($) carp "Warning[$appName] Can't set flags for the socket: $!\n"; return; } + $appSock->sockopt(Socket::TCP_NODELAY, TCP_NO_DELAY_ACTIVATED); + binmode ($appSock); # on cree une entree pour $appSock dans la liste des regexp @@ -1443,8 +1457,10 @@ sub _getConnections ($) unless (fcntl($appSock, F_SETFL, $flags | O_NONBLOCK)) { carp "Can't set flags for the socket: $!\n"; return; - binmode ($appSock); } + + $appSock->sockopt(Socket::TCP_NODELAY, TCP_NO_DELAY_ACTIVATED); + binmode ($appSock); } @@ -1704,7 +1720,11 @@ sub _getMessages ($$) $self->_pong ($appSock, $id); } - elsif ($type == PONG) { + +# le traitement est basique, ne fonctionne que si le recepteur traite le pong +# avant qu'il n'envoie un deuxieme ping. Si les pings sont envoyés trop rapidement, +# aucun pong ne sera émit. + elsif ($type == PONG) { if (exists $self->[pongQueue]->{$appSock}) { my ($pingid, $time, $funcRef) = @{$self->[pongQueue]->{$appSock}}; # printf ("DBG>>> stocked Id = $pingid;; message id = $id\n"); @@ -2860,9 +2880,9 @@ Send a suicide to the application named $to. =item B<ping> $ivyobj->ping($to, $timeout); - Ivy::ping($to, $timeout); + Ivy::ping($to, \&callBack); -Send a ping message and wait until timeout to receive a pong. +Send a ping message, callBack will be called on response. =item B<after> |