how to get any available port
Mohammed Smadi
smadim2 at grads.ece.mcmaster.ca
Tue Oct 4 17:19:37 EDT 2005
On Tue, 4 Oct 2005, Grant Edwards wrote:
> On 2005-10-04, ncf <nothingcanfulfill at gmail.com> wrote:
>
> > Hmm...perhaps he is trying to do a transfer thing like many chat
> > programs do. Instead of sending large files across a server, you
> > "Direct Connect" and send the file directly. :shrugs:
>
> So how does that require binding the client end of a TCP
> connection?
>
>
what else would you do? I am using examples from the web and they all
bind to a port at the localhost before connecting to the remote host.
my code is like this
#transmission socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("",hp_port)) # do some error checking
data="HI"
print data
s.connect(('192.168.2.13',port))
s.send(data)
print "\n"
which is working fine for me after putting the
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) statement
any suggestions for alternative implementation?
moe smadi
More information about the Python-list
mailing list