Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94569

Re: UDP and Python2.7 and 2.7 documentation gives error!

From Laura Creighton <lac@openend.se>
Subject Re: UDP and Python2.7 and 2.7 documentation gives error!
References <55B3C31D.7000205@meditalk.com>
Date 2015-07-25 19:56 +0200
Newsgroups comp.lang.python
Message-ID <mailman.990.1437847023.3674.python-list@python.org> (permalink)

Show all headers | View raw


In a message of Sat, 25 Jul 2015 19:10:53 +0200, Nils writes:
>UDP and Python2.7 and 2.7 documentation gives error!
>I am trying to send UDP messages from one PC to another, using P2.7.
>BUT I get an error I do not understand, this as I am following the doc's
>for Python2.7! Listing of the script with error result following:
>
>import socket
>
>UDP_IP = '192.168.0.90'
>UDP_PORT = 45121
>msg = '7654321'
>
>print ("UDP target IP:", UDP_IP)
>print ("UDP target port:", UDP_PORT)
>print ("message:", msg)
>
>sock = socket.socket(socket.AF_INET, # Internet
>                     socket.SOCK_DGRAM) # UDP
>sock.bind((UDP_IP, UDP_PORT))
>sock.send( msg )
>
>
>C:\Utveckling\Counter_python>Counter_send.py
>('UDP target IP:', '192.168.0.90')
>('UDP target port:', 45121)
>('message:', '7654321')
>Traceback (most recent call last):
>  File "C:\Utveckling\Counter_python\Counter_send.py", line 13, in <module>
>    sock.bind((UDP_IP, UDP_PORT))
>  File "C:\Python27\lib\socket.py", line 228, in meth
>    return getattr(self._sock,name)(*args)
>socket.error: [Errno 10049] The requested address is not valid in its
>context
>
>C:\Utveckling\Counter_python>
>
>So, please tell me where I am doing wrong, or is doc's wrong??
>Nils in Uppsala

Does ipconfig report that 192.168.0.90 is something you can bind to?
If not, that is your problem.  It needs to be something on localhost
that you can bind to.

Laura

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: UDP and Python2.7 and 2.7 documentation gives error! Laura Creighton <lac@openend.se> - 2015-07-25 19:56 +0200

csiph-web