Re: accessing RR TCP connection sockets

[email protected] (Jonas Borgström) 19 Nov 2002 11:11:48 +0100
Newsgroups gmane.network.beep.roadrunner.general
Message-ID <[email protected]>
Nick Hertl <[email protected]> writes:

> I am part of a team of college students implementing TUNNEL as a BEEP profile.
> We are using RoadRunner as our primary source of BEEP libraries and have run
> into a problem that we'd like to ask a question about.
> 
Cool, are you planning to use it together with the IDXP profile?

> If we are the recipient of a BEEP connection and we want to connect that
> one to a new connection, what's the best way?  Ideally we would just join
> the two sockets together so data coming in on either one just goes directly
> into the other untouched.  The problem here is two-fold.
> 
> 1) We can't find information on how to access the socket of a roadrunner
> connection.  This is needed so we can join the two for communication.

rr_tcp_connection_get_fd (RR_TCP_CONNECTION (conn)) should do the trick.
> 
> 2) We don't' know of a way to close a roadrunner connection without closing
> the underlying socket.  This is needed to prevent roadrunner from messing with
> the data coming through.
> 
> We basically want to be able to take an existing connection, create another
> one, join those two sockets bidirectionally to get out of the way, and have
> roadrunner stop doing anything and go away without killing the socket.  Is
> this possible?
> 

I think this might work:
  g_io_channel_set_close_on_unref (RR_TCP_CONNECTION (conn)->iochannel, FALSE);

> We have looked into a workaround to prevent being totally Dead In The Water.
> We can put a "filter" onto the connection such that data coming in on one
> connection goes to another, but we don't really feel like that's the "right"
> way to do this.  It adds an extra layer of complexity which will definitely
> cause some performance hit at the very least.
> 

After the tunnel has been configured, RoadRunner can forget all about it. The
only thing you need to do is to copy data between two file descriptors. And the
easiest way to do this is probably to use the glib event loop.

I wrote a tunnel profile for beepcore-c a year ago and used a thread for each
connection "tunneled". But glib should be a cleaner solution.

/ Jonas
-- 
Jonas Borgström                  [email protected]
CodeFactory AB                   http://www.codefactory.se/
Office: +46 (0)90 71 86 14