Forum: Ruby TCPServer locking when calling accept

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Baf018e2cc4616e4776d323215c7136c?d=identicon&s=25 Alex MacCaw (Guest)
on 2007-04-03 22:37
How do I stop the TCPServer 'locking up' when I call accept?
I'm trying to build a passive ftp server.
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (Guest)
on 2007-04-03 23:25
(Received via mailing list)
On Wed, Apr 04, 2007 at 05:37:40AM +0900, Alex MacCaw wrote:
> How do I stop the TCPServer 'locking up' when I call accept?
> I'm trying to build a passive ftp server.

Start a new thread for each incoming connection.

There's example code (a dummy POP3 server) at
http://www.rubygarden.org/ruby?SingletonTutorial

... except RubyGarden seems to be down again, so try entering this URL
in
the waybackmachine at www.archive.org

Regards,

Brian.
7b83481be2f1ce5723b2350f02338bf3?d=identicon&s=25 Louis R. Marascio (Guest)
on 2007-04-04 03:58
(Received via mailing list)
Alex MacCaw <maccman@gmail.com> wrote:
>How do I stop the TCPServer 'locking up' when I call accept?
>I'm trying to build a passive ftp server.

When you say 'locking up' do you mean it won't return from the method
call until a client has connected? If so, this is typically referred to
as 'blocking'. There is a method on TCPServer called 'accept_nonblock'
that may give you the behavior you are looking for.

Best regards,

Louis
This topic is locked and can not be replied to.