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

Steve Huston shuston at riverace.com
Wed Feb 13 11:17:57 CST 2008


Hi Jim,

If you want the threads to use different sockets (and therefore
different local port numbers), make sure that tcpStream is not a
single object accessed via both threads.

Best regards,
-Steve

--
Steve Huston, Riverace Corporation
Want to take ACE training on YOUR schedule?
See http://www.riverace.com/training.htm


> -----Original Message-----
> From: ace-users-bounces at cse.wustl.edu 
> [mailto:ace-users-bounces at cse.wustl.edu] On Behalf Of Jim Hodapp
> Sent: Wednesday, February 13, 2008 11:35 AM
> To: ace-users at cs.wustl.edu
> Subject: [ace-users] Getting a TCP socket connection with a 
> unique port perthread
> 
> 
> 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
> 
> _______________________________________________
> ace-users mailing list
> ace-users at mail.cse.wustl.edu
> http://mail.cse.wustl.edu/mailman/listinfo/ace-users
> 




More information about the Ace-users mailing list