[newbie] trying socket as a replacement for nc

Roy Smith roy at panix.com
Sun Dec 15 18:44:32 CET 2013

In article <mailman.4143.1387123508.18130.python-list at python.org>,
 Chris Angelico <rosuav at gmail.com> wrote:

> On Mon, Dec 16, 2013 at 2:51 AM, Roy Smith <roy at panix.com> wrote:
> > In article <l8kh1r$bj8$1 at reader1.panix.com>,
> >  Grant Edwards <invalid at invalid.invalid> wrote:
> >
> >> UDP is a a _datagram_ service. Either all the bytes in a write()
> >> should get sent or none of them. Sending a paritial datagram is _not_
> >> a valid option.
> >
> > I would agree with the above if you said send() instead of write().
> > Python socket objects don't have write() methods, file objects do.  You
> > can wrap a file around a socket with socket.makefile(), but I'm not sure
> > I would expect the UDP record boundary semantics to be honored once you
> > did that.
> The underlying C API allows you, on Unix-like systems at least, to use
> the standard write() function to send UDP packets (as long as you
> first connect() - otherwise you need sendto() to specify a
> destination). I don't usually use that method, but I would expect that
> one call to write() becomes one UDP packet.

At the Unix system call level, yes.  But, given that this is a Python 
newsgroup, I made the assumption we were talking about the Python API 
level.  Silly me :-)

More information about the Python-list mailing list