Home Help Center

single stream for two-way communication?

vukicevicvukicevic Member Vladimir VukicevicOrganization: DUGProject: DUG Insight ✭✭
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

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    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.
  • vukicevicvukicevic Member Vladimir VukicevicOrganization: DUGProject: DUG Insight ✭✭
    I completely missed -c. Looks pretty straightforward, thank you for the info.. and for the quick reply!

    -- Vlad
Sign In or Register to comment.