… | |
… | |
38 | use AnyEvent (); |
38 | use AnyEvent (); |
39 | use AnyEvent::Util (); |
39 | use AnyEvent::Util (); |
40 | |
40 | |
41 | use AnyEvent::MP; |
41 | use AnyEvent::MP; |
42 | use AnyEvent::MP::Kernel (); |
42 | use AnyEvent::MP::Kernel (); |
43 | use AnyEvent::MP::Global (); |
|
|
44 | |
43 | |
45 | our $ID = "a"; |
44 | our $ID = "a"; |
46 | our %STATE; |
45 | our %STATE; |
47 | |
46 | |
48 | # another node tells us to await a connection |
47 | # another node tells us to await a connection |
… | |
… | |
103 | |
102 | |
104 | my $transport; $transport = AnyEvent::MP::Transport::mp_connect |
103 | my $transport; $transport = AnyEvent::MP::Transport::mp_connect |
105 | $host, $port, |
104 | $host, $port, |
106 | protocol => "aemp-dataconn", |
105 | protocol => "aemp-dataconn", |
107 | local_greeting => { dataconn_id => $id }, |
106 | local_greeting => { dataconn_id => $id }, |
108 | sub { $transport->destroy }, #TODO: destroys handshaked conenctions too early |
107 | sub { $transport->destroy }, #TODO: destroys handshaked connections too early |
109 | ; |
108 | ; |
110 | }; |
109 | }; |
111 | } |
110 | } |
112 | |
111 | |
113 | =item AnyEvent::MP::DataConn::connect_to $node, $timeout, $initfunc, @initdata, $cb->($handle) |
112 | =item AnyEvent::MP::DataConn::connect_to $node, $timeout, $initfunc, @initdata, $cb->($handle) |
114 | |
113 | |
115 | Creates a socket connection between the local node and the node C<$node> |
114 | Creates a socket connection between the local node and the node C<$node> |
116 | (which can also be specified as a port). One of the nodes must have |
115 | (which can also be specified as a port). One of the nodes must have |
117 | listening ports ("binds"). |
116 | listeners ("binds"). |
118 | |
117 | |
119 | When the connection could be successfully created, the C<$initfunc> |
118 | When the connection could be successfully created, the C<$initfunc> |
120 | will be called with the given C<@initdata> on the remote node (similar |
119 | will be called with the given C<@initdata> on the remote node (similar |
121 | to C<snd_to_func> or C<spawn>), and the C<AnyEvent::Handle> object |
120 | to C<snd_to_func> or C<spawn>), and the C<AnyEvent::Handle> object |
122 | representing the remote connection end as additional argument. |
121 | representing the remote connection end as additional argument. |