Two Pythons talking to each other?

phil phil at ricochet.net
Thu Jul 8 03:04:44 EDT 1999


On Thu, 8 Jul 1999 05:30:40 GMT, "Hans Nowak" <ivnowa at hvision.nl>
wrote:

>
>On 7 Jul 99, Charles G Waldman wrote:
>
<snip good solution>
>
<snip good question>
>
>So my question is, how does one generally deal with this? Should I 
>attach a newline (\n) (or maybe another separator character) after 
>every string? Or are there other ways to guarantee that two commands 
>will arrive at the other side as two strings?
>
The primary protocols are TCP and UDP. UDP is non-connection oriented
and will deliver a datagram. Sending a packet from one side to the
other followed by another packet will not coalesce the packets into
one. However, seems to me that you really want a session oriented
solution. I suspect that the guys in the sockets group will tell you
that a TCP connection is a stream, so all bets are off. Sending "hello
wordl. " followed by sending "hello snailor" might result in receiving
"hello wordl.hel" and "lo snailor".  The solution is to impose your
own protocol on top of this using TCP as a delivery mechanism.
Something as simple as <NL> delimiting  might do it for you. 

If  the localhost address works ok, you can also use the local machine
name or the local IP address to open connections and this should ease
the move to running on separate machines.

TCP/IP seems to work in lots of places'ly yrs.
(did i get that right?).

phil.





More information about the Python-list mailing list