Archived

This forum has been archived. Please start a new discussion on GitHub.

single stream for two-way communication?

From looking at the documentation, it seems that if I want to use a single TCP stream for all communication (two-way, even, between client and server), I'd have to use Glacier on the server side, and use GlacierStarter. There is some mention of the stream staying alive for two-way communication only while there is an active connection up -- what's the canonical way to create a connection and keep it around for the lifetime of the client?

Also, along with a two-way tcp stream, I'd like to create a parallel UDP port set to use for communication (specifically server-to-client IceStorm broadcasts). However, to get through common NAT setups, the client would need to initiate this connection, and the server would need to use the src udp port as the destination. I've got some ideas on how to set this up, but I'd be interested to hear if there's a standard way of doing this.

Thanks!

Comments

  • marc
    marc Florida
    Re: single stream for two-way communication?
    Originally posted by vukicevic
    From looking at the documentation, it seems that if I want to use a single TCP stream for all communication (two-way, even, between client and server), I'd have to use Glacier on the server side, and use GlacierStarter. There is some mention of the stream staying alive for two-way communication only while there is an active connection up -- what's the canonical way to create a connection and keep it around for the lifetime of the client?

    You don't have to do anything special. As soon as an outgoing connection is also used for dispatching incoming requests, such connection will stay alive until you destroy the object adapter for the incoming requests.
    Originally posted by vukicevic

    Also, along with a two-way tcp stream, I'd like to create a parallel UDP port set to use for communication (specifically server-to-client IceStorm broadcasts). However, to get through common NAT setups, the client would need to initiate this connection, and the server would need to use the src udp port as the destination. I've got some ideas on how to set this up, but I'd be interested to hear if there's a standard way of doing this.

    Thanks!

    Yes, this works, too. It's quite easy: You must use a "connected" UDP endpoint for the Glacier router. This way, the router port used to receive UDP packets from the client will also be used to send UDP packets back to the client.

    A UDP endpoint becomes "connected" by using the -c option. From the manual:

    -c Specifies that a connected UDP socket should be used. Causes the server to connect to the socket of the first peer that sends a datagram to this endpoint.
  • I completely missed -c. Looks pretty straightforward, thank you for the info.. and for the quick reply!

    -- Vlad