On 21/10/2010 15:57, Todd Walter wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, 21 Oct 2010 00:07:58 +0100
MRAB<pyt...@mrabarnett.plus.com> wrote:
[snip]
The docs for 'sendto' say:
"""The socket should not be connected to a remote socket, since
the destination socket is specified by address."""
Could your problem be caused by you binding the socket to a source
port, so it's going out both to the bound port _and_ the one given the
binding?
Have you tried using two sockets, one outgoing and the other incoming?
BTW, your code for handling the response doesn't cope with it coming
in a bit at a time. It loops discard any previous data from the
previous iteration.
Also, it's more Pythonic to say:
while '\r' not in response:
...
I haven't bound the socket to a remote port, as I read it; it's bound to
a source port (192.168.10.2:2260, the local machine) and just transmits
to an address with a port glommed on (192.168.10.1:2002, the PLC).
[snip]
What I meant was that you're using 'pcSocket' for both directions and
using .bind on it.
Try creating two sockets, 'pcInSocket' and 'pcOutSocket', and bind only
pcOutSocket.
--
http://mail.python.org/mailman/listinfo/python-list