[EMAIL PROTECTED] wrote:
> Apparently, calling bind() with a zero "port" will choose some available port
> number, as demonstrated by this program:
>
> import socket
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.bind(("", 0))
> print s.getsockname()
>
> Here's how it behaved over se
In article <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> wrote:
.
.
.
>Here's how it behaved over several runs:
>$ python soc.py
>('0.0.0.0', 34205)
>$ python soc.py
>('0.0.0.0', 34206)
>$ python soc.py
>('0.0.0.0', 34207)
>
>I
"Fredrik Lundh" <[EMAIL PROTECTED]> writes:
> Grant Edwards wrote:
> > IIRC, you just call bind() with a port number of zero, and then
> > use some method-or-other on the bound socket to find out what
> > port it's bound to.
>
> >>> s = socket.socket()
> >>> s.bind(("", 0))
> >>> s.getsockaddr()
>
Grant Edwards wrote:
> IIRC, you just call bind() with a port number of zero, and then
> use some method-or-other on the bound socket to find out what
> port it's bound to.
>>> s = socket.socket()
>>> s.bind(("", 0))
>>> s.getsockaddr()
("0.0.0.0", 4711)
--
http://mail.python.org/mailman/l
On 2005-10-04, Paul Rubin <> wrote:
> Grant Edwards <[EMAIL PROTECTED]> writes:
>> > In the nomenclature of some of these applications, that kind
>> > of transfer is called a client to client connection. Both
>> > ends are called clients.
>>
>> IIRC, we were talking about TCP sockets.
> So, ther
On 2005-10-04, Paul Rubin <> wrote:
> Mohammed Smadi <[EMAIL PROTECTED]> writes:
>> #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
>> ...
>> any suggestions fo
On 2005-10-04, Mohammed Smadi <[EMAIL PROTECTED]> wrote:
> On Tue, 4 Oct 2005, Grant Edwards wrote:
>
>> On 2005-10-04, ncf <[EMAIL PROTECTED]> 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
>> >
Mohammed Smadi wrote:
> 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.
pointers, please.
> my code is like this
>
> #transmission socket
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.se
Mohammed Smadi <[EMAIL PROTECTED]> writes:
> #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
> ...
> any suggestions for alternative implementation?
In this parti
On Tue, Oct 04, 2005 at 05:19:37PM -0400, Mohammed Smadi wrote:
> 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.
[...]
the web must be stupider than I thought.
Here's how Python's own ftplib connects
Grant Edwards <[EMAIL PROTECTED]> writes:
> > In the nomenclature of some of these applications, that kind
> > of transfer is called a client to client connection. Both
> > ends are called clients.
>
> IIRC, we were talking about TCP sockets.
Yes, but if the person was talking about using TCPs s
On Tue, 4 Oct 2005, Grant Edwards wrote:
> On 2005-10-04, ncf <[EMAIL PROTECTED]> 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 ho
Apparently, calling bind() with a zero "port" will choose some available port
number, as demonstrated by this program:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("", 0))
print s.getsockname()
Here's how it behaved over several runs:
$ python soc.py
('0.0.0.0', 34
On 2005-10-04, Paul Rubin <> wrote:
> Grant Edwards <[EMAIL PROTECTED]> writes:
>> > 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 t
Grant Edwards <[EMAIL PROTECTED]> writes:
> > 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
On 2005-10-04, ncf <[EMAIL PROTECTED]> 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
conn
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:
--
http://mail.python.org/mailman/listinfo/python-list
Mohammed Smadi wrote:
> if am using s.bind for a tcp socket. On the client side i dont really
> care which socket i use as long as i get an available socket. Is there a
> funciton or a way to get an available socket?
why are you using bind if you're on the client side?
--
http://mail.pyt
hi;
if am using s.bind for a tcp socket. On the client side i dont really
care which socket i use as long as i get an available socket. Is there a
funciton or a way to get an available socket?
thanks
smadi
--
http://mail.python.org/mailman/listinfo/python-list
19 matches
Mail list logo