Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.protocols.tcp-ip    |    TCP and IP network protocols.    |    14,669 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 13,675 of 14,669    |
|    umutlu to Lew Pitcher    |
|    Re: TCP source port    |
|    29 Oct 10 17:51:48    |
   
   From: invalid@invalidinvalid.org   
      
   On 2010-10-25 16:17, Lew Pitcher wrote:   
   > On October 25, 2010 09:35, in comp.protocols.tcp-ip,   
   > miguelsanders@telenet.be wrote:   
   >   
   >> Is there any way how a TCP/IP C programmer can have more control on   
   >> the source TCP port that will be used to setup the socket ?   
   >   
   > Use a bind(2) call ("man 2 bind") to connect your socket to a specific   
   > source port number.   
      
   Ok, normally the OS assigns randomly a free local port if one   
   doesn't bind the socket to a specific port.   
   But, for a special application I need to use raw sockets, ie.   
    s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);   
   Now, I would use a free random local port as the source port,   
   but don't know how to get one. Is there a method to get such   
   a port, and inform the OS (Linux) about the fact that   
   this port is going to be used, so to prevent a possible use   
   attempt of the same port by the normal socket functions?   
      
   --   
   Uenal Mutlu, Hannover/Germany   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca