[Xorp-hackers] Events and sockets in XORP

Pavlin Radoslavov pavlin at ICSI.Berkeley.EDU
Mon Feb 2 01:51:45 PST 2009


Victor Faion <vfaion at gmail.com> wrote:

> > To send/receive TCP you can do it via the FEA so you don't have to
> > deal with sockets, etc.
> > Basically, you need to use the xrl/interfaces/socket4.xif XRL API to
> > register with the FEA to send/receive TCP.
> > Then in your protocol you need to implement the receiving (target)
> > side of socket4_user.xif .
> > The XRL library itself will take care of the rest: on reception it
> > will call the appropriate socket4_user.xif method.
> > Once you process the event, just return back to the eventloop.
> >
> 
> I implemented these functions (basically just printing out their parameters):
> 
> socket4_user_0_1_recv_event
> socket4_user_0_1_inbound_connect_event
> socket4_user_0_1_outgoing_connect_event
> socket4_user_0_1_disconnect_event
> socket4_user_0_1_error_event
> 
> I'm not sure how to register with the FEA, I was trying to call
> send_tcp_listen in my startup function, but I didn't know what
> parameters to use (especially the sockid).
> 
> The documentation on that function says:
> Listen for inbound connections on socket. When a connection request
> received the socket creator will receive notification through
> socket4_user/0.1/inbound_connect_event.
> 
> Does this mean the callback parameter should be my implementation of
> inbound_connect_event, or is the callback passed just supposed to
> generate some error if listening on a socket didn't succeed?
> 
> For the destination target name I was passing
> "socket4/0.1/tcp_listen", but I'm not sure if this is the right thing
> to use.

First you need to open the TCP socket by using one of the tcp_open*
XRLs, which will give you the sockid. Then you can use sockid for
additional operations on the socket.

You might also have a look at fea/test_xrl_sockets4_tcp.cc for usage
of some of the TCP-related XRLs.

Pavlin



More information about the Xorp-hackers mailing list