3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
|
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
|
+
-
+
+
-
+
+
+
+
+
+
+
|
}
# Used to just start listening
if {$address eq "" || $port eq ""} {
return
}
set addressVersion [::ip::version $address]
set protocolVersion "v[::ip::version $address]"
set protocolVersion "v$addressVersion"
set socket $::nano::node::realtime::socket($protocolVersion)
set peerSock [list type "realtime" remote [list $address $port] socket $socket]
} elseif {$type eq "bootstrap"} {
set peerSock [::nano::network::_connect $address $port]
} else {
return -code error "Unknown network type: $type"
}
return $peerSock
}
proc ::nano::node::realtime::incoming {socket} {
set data [read $socket 8192]
if {$data eq ""} {
return
}
set remote [chan configure $socket -peer]
set address [lindex $remote 0]
set port [lindex $remote 1]
catch {
set peerSock [::nano::node::createSocket realtime $address $port]
set peerSock [::nano::node::createSocket realtime $address $port]
}
if {![info exists peerSock]} {
::nano::node::log "Error: Unable to create socket from address \"$address\" port \"$port\""
return
}
set response [::nano::network::server $data "realtime" $peerSock]
if {$response eq ""} {
return
}
set response [dict get $response "invoke_client"]
|