sending a file through sockets
brueckd at tbye.com
brueckd at tbye.com
Sat Jul 6 02:46:56 EDT 2002
On Fri, 5 Jul 2002, Bryan Olson wrote:
> > Anyway, here's some sample code, but if
> > you're not already familiar with sockets then you should spend a little
> > time experimenting with them.
>
> Did you test this?
Heaven's no! ;-) I shoulda included the standard 'not tested' disclaimer,
although I use similar code all the time...
> The Python library uses the empty string for
> INADDR_ANY, which is fine for bind(), but I don't think it's legal for
> connect().
Try it and be amazed! ;-)
> I understand it's a basic demo, but I'll note that any real application
> requires some time-out discipline to avoid very long hangs.
Depends on your definition of 'real' of course. The simplest thing to do
is just import timeoutsocket and set a default timeout and then the posted
code works without modification. In my really real (production) code I
usually use poll anyway, but I don't think that would have helped the OP
much.
> Also on
> most Unix systems we'd need to watch out for signals that force system
> calls to return.
Hmm.. really depends on your application and which signals. For example,
signal 2 gets translated into a Python KeyboardInterrupt, so you wouldn't
handle it any differently. Most other signals kill the interpreter, which
is fine with me.
-Dave
More information about the Python-list
mailing list