Re: sockets -- basic udp client

2008-02-17 Thread 7stud
On Feb 17, 12:15 pm, [EMAIL PROTECTED] (Douglas Wells) wrote: > > For example: > > > import socket, sys > > > host =  'localhost'  #sys.argv[1] > > port = 3300 > > s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > > > s.settimeout(1.0) > > buf = '' > > > data = 'hello world' > > num_sent = 0 >

Re: sockets -- basic udp client

2008-02-17 Thread Douglas Wells
In article <[EMAIL PROTECTED]>, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: I have had some difficulty following the assertions, corrections, and misquoting in this article thread, so apologies in advance if I have missed a correction or misunderstood an assertion. [ quoting partially corre

Re: sockets -- basic udp client

2008-02-17 Thread Roy Smith
In article "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > If you don't care about the address of the sender, e.g. you are not > going to send anything back, is there an advantage to using recv()? At the system call level, recv() is marginally faster since there's less data to pass back and fort

Re: sockets -- basic udp client

2008-02-17 Thread Steve Holden
Paul Rubin wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> Historically, though, the ultimate authority on this kind of stuff is >> Richard Stevens and his Unix and TCP/IP books >> >> I recommend these books if you want to get into network programming. > > I keep wanting to get that bo

Re: sockets -- basic udp client

2008-02-16 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Historically, though, the ultimate authority on this kind of stuff is > Richard Stevens and his Unix and TCP/IP books > > I recommend these books if you want to get into network programming. I keep wanting to get that book, but it gets older and o

Re: sockets -- basic udp client

2008-02-16 Thread [EMAIL PROTECTED]
If you don't care about the address of the sender, e.g. you are not going to send anything back, is there an advantage to using recv()? Or, as a matter of course should you always use recvfrom() with udp sockets? I don't know of a reason why you couldn't use recvfrom() all the time, and that is w

Re: sockets -- basic udp client

2008-02-16 Thread 7stud
On Feb 16, 6:32 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > >> That example is plain wrong; looks like some TCP code but with   > >> SOCK_STREAM   > >> blindy replaced with SOCK_DGRAM. connect, sendall and recv are not used   > >> for UDP; sendto and recvfrom are used instead. There are so

Re: sockets -- basic udp client

2008-02-16 Thread 7stud
On Feb 16, 6:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > Here is the example above converted to a more straightforward udp > client that isolates the part I am asking about: > > import socket, sys > > host =  'localhost'

Re: sockets -- basic udp client

2008-02-16 Thread Gabriel Genellina
En Sat, 16 Feb 2008 05:56:39 -0200, 7stud <[EMAIL PROTECTED]> escribi�: >> > while 1: >> >     buf = s.recv(2048) >> >     if not len(buf): >> >         break >> >     print "Received: %s" % buf >> >> > As far as I can tell, the if statement: >> >> > if not len(buf): >> >    break >> >> > does n

Re: sockets -- basic udp client

2008-02-16 Thread [EMAIL PROTECTED]
Here is the example above converted to a more straightforward udp client that isolates the part I am asking about: import socket, sys host = 'localhost' #sys.argv[1] port = 3300 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM

Re: sockets -- basic udp client

2008-02-16 Thread 7stud
On Feb 15, 6:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 15 Feb 2008 20:24:19 -0200, 7stud <[EMAIL PROTECTED]>   > escribió: > > > > > My question pertains to this example: > > > #!/usr/bin/env python > > > import socket, sys, time > > > host = sys.argv[1] > > textport = sys.arg

Re: sockets -- basic udp client

2008-02-15 Thread Gabriel Genellina
En Fri, 15 Feb 2008 20:24:19 -0200, 7stud <[EMAIL PROTECTED]> escribió: > My question pertains to this example: > > #!/usr/bin/env python > > import socket, sys, time > > host = sys.argv[1] > textport = sys.argv[2] > > s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > try: > port = int(

sockets -- basic udp client

2008-02-15 Thread 7stud
My question pertains to this example: #!/usr/bin/env python import socket, sys, time host = sys.argv[1] textport = sys.argv[2] s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: port = int(textport) except ValueError: # That didn't work. Look it up instread. port = socket.ge