[Ace-users] [ace-users] Getting a TCP socket connection with a unique port per thread

Jim Hodapp james.hodapp at gmail.com
Wed Feb 13 12:19:52 CST 2008


I believe that I might have solved my own problem, though I'd still be  
curious if I'm setting things up correctly with the ACE_SOCK_Connector  
with the desired behavior that I described.

Jim


On Feb 13, 2008, at 11:35 AM, Jim Hodapp wrote:

> I am trying to use ACE to connect to a single TCP server on port  
> 554. I am using an ACE_SOCK_Connector and ACE_SOCK_Stream for this.  
> I have this connection being established in a class of mine that  
> inherits from ACE_Task<ACE_MT_SYNCH> specifically. I cannot seem to  
> get this connection to occur via a unique source TCP port number  
> randomly selected by the OS. I am doing the following to establish  
> my connection:
>
> void myConnectFunction()
> {
> ACE_INET_Addr address(this->RTSPServerPort, this->serverIP.c_str());
> ACE_SOCK_Connector serverConnector;
> ACE_Time_Value cTimeout(Connection::connectTimeout);
>
> while (serverConnector.connect(tcpStream, address, &cTimeout) == -1)
> {
> 	// Check for errors, timeouts, etc...
> }
> }
>
> mySendFunction(const Payload *payload)
> {
> ACE_Time_Value sTimeout(this->sendTimeout);
> if (this->tcpStream.send_n(payload->getPayload().c_str(), payload- 
> >getPayload.length(), &sTimeout) == -1)
> {
> 	// Check for errors, timeouts, etc...
> }
> }
>
> Each of these functions are both called per each thread instance. I  
> cannot get any of the sends to go out on anything but the same  
> source port number. I need these to be different port numbers. Is  
> there something obvious I'm doing wrong?
>
> I'm using ACE version 5.4.7 (as packaged by Ubuntu Linux 7.10).
> OS: Ubuntu Linux 7.10
>
> Any help would be appreciated.
>
> Jim



More information about the Ace-users mailing list