Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > why does socket.makefile require non-blocking mode?

Reply
Thread Tools

why does socket.makefile require non-blocking mode?

 
 
Forest
Guest
Posts: n/a
 
      03-28-2008
The socket.makefile() docs say, "the socket must be in blocking mode." I
don't see any explanation of why blocking mode is required, and I'm not sure
whether that means timeout mode is forbidden as well. Can someone clarify
this?

I wanted to use file-like objects with socket timeouts, so I ended up writing
my own replacement for socket._fileobject. I'd appreciate it if someone could
either explain to my why my new class was unnecessary, or else encourage me to
contribute it as a patch to the socket module.

Cheers,

Forest






 
Reply With Quote
 
 
 
 
Bryan Olson
Guest
Posts: n/a
 
      03-29-2008
Forest wrote:
> The socket.makefile() docs say, "the socket must be in blocking mode." I
> don't see any explanation of why blocking mode is required, and I'm not sure
> whether that means timeout mode is forbidden as well. Can someone clarify
> this?


Looking at the code for the existing _fileobject's read method, it
will loose data it has already read if a socket.recv() call raises
an exception. The function keeps buffers in a local variable that
will be lost if an exception exits the scope. That much could be
fixed with a try...finally. Other methods have similar problems.

> I wanted to use file-like objects with socket timeouts, so I ended up writing
> my own replacement for socket._fileobject. I'd appreciate it if someone could
> either explain to my why my new class was unnecessary, or else encourage me to
> contribute it as a patch to the socket module.


Sure, fix it. A harder problem is that it doesn't play nice with select().


--
--Bryan



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Why does a Microsoft wheel mouse require software installation ? wylbur37 Computer Support 5 01-18-2005 02:05 PM
Re: Why does using keyword require a new scope? Jip from Paris ASP .Net 0 08-25-2003 08:02 AM
Re: Why does using keyword require a new scope? Herman Eldering ASP .Net 0 08-23-2003 11:32 PM



Advertisments