Two Pythons talking to each other?

Scott Wolford wolford at enews.nrl.navy.mil
Thu Jul 8 12:44:49 EDT 1999


How about preceding the string with the length of the string, like if you were
reading and writing from a binary file. Or possibly a NUL character (unless you
plan to embed NUL's in your string.

Scott

Hans Nowak wrote:

> I just tested this, and it works. But now I have another problem &
> question (which may be stupid, but I know hardly anything about
> networking and sockets). My programs send commands to each other in
> IRC style (like "/say this") or just plain text (chat). For receiving
> these strings, I use a non-blocking socket connection which polls the
> server every 0.x seconds (the period may vary). However, when the
> strings are sent too fast, which is the case with the 127.0.0.1
> address, and sometimes with regular connections too, the other side
> will pick two strings up as one string.
>
> 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?
>
> TIA,
>
> --Hans Nowak (ivnowa at hvision.nl)
> Homepage: http://fly.to/zephyrfalcon





More information about the Python-list mailing list