Hello,
I am using socket4 library and I am trying to check if a neighbor A is
reachable.
I did something like :
void
SocketClient::connect() {
XorpCallback2<void, const XrlError&, const string*>::RefPtr cb;
cb = callback(this,&SocketClient::connect_cb);
send_tcp_open_bind_connect("fea",_rtr.instance_name(),_localIP,_localPort,_remoteIP,_remotePort,cb);
}
void
SocketClient::connect_cb(const XrlError& e,const string* socket_id) {
if (e != XrlError::OKAY()) {
XLOG_ERROR("%s\n", "Error");
} else {
_socket_id = *socket_id;
_connected = true;
}
}
SocketClient::send_data(vector<uint8_t> data) {
if(connected()) {
XLOG_INFO("%s\n", "Try to send data...");
XorpCallback1<void, const XrlError&>::RefPtr cb;
cb = callback(this,&SocketClient::send_data_cb);
send_send("fea",_socket_id,data,cb);
//send_send_to("fea",_socket_id,_remoteIP,_remotePort,data,cb);
}
}
void
SocketClient::send_data_cb(const XrlError& e) {
if(e!=XrlError::OKAY()) {
XLOG_ERROR("%s %s\n", "ERROR :",e.str().c_str());
} else {
XLOG_INFO("%s\n", "Packet send");
}
_is_waiting = false;
}
I was supposing that if the neighbor doesn't exist, socket4 will return
an error on connect_cb function, but apparently it doesnt.
When I run this code with a remote neighbor which doesn't exist, I got
an error :
[ 2009/03/02 14:59:23 INFO xorp_consensus CONSENSUS ] Try to send data...
[ 2009/03/02 14:59:23 ERROR xorp_fea:3591 LIBXORP +811 asyncio.cc start
] AsyncFileWriter: Failed to add I/O event callback.
[ 2009/03/02 14:59:23 INFO xorp_consensus CONSENSUS ] Packet send
So I don't really know how to check if a neighbor is reachable or not.
Can you help me???
Thank you!
Michael
_______________________________________________
Xorp-hackers mailing list
[email protected]
http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers