Linux heracles.o2switch.net 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
/
opt
/
alt
/
ruby21
/
share
/
ri
/
2.1.0
/
system
/
Socket
/
//opt/alt/ruby21/share/ri/2.1.0/system/Socket/accept_nonblock-i.ri
U:RDoc::AnyMethod[iI"accept_nonblock:ETI"Socket#accept_nonblock;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I":Accepts an incoming connection using accept(2) after ;TI";O_NONBLOCK is set for the underlying file descriptor. ;TI"8It returns an array containing the accepted socket ;TI"3for the incoming connection, _client_socket_, ;TI"(and an Addrinfo, _client_addrinfo_.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI"Example;To:RDoc::Markup::Verbatim; [I"'# In one script, start this first ;TI"require 'socket' ;TI"include Socket::Constants ;TI"2socket = Socket.new(AF_INET, SOCK_STREAM, 0) ;TI"6sockaddr = Socket.sockaddr_in(2200, 'localhost') ;TI"socket.bind(sockaddr) ;TI"socket.listen(5) ;TI"%begin # emulate blocking accept ;TI"? client_socket, client_addrinfo = socket.accept_nonblock ;TI"+rescue IO::WaitReadable, Errno::EINTR ;TI" IO.select([socket]) ;TI" retry ;TI" end ;TI"?puts "The client said, '#{client_socket.readline.chomp}'" ;TI"1client_socket.puts "Hello from script one!" ;TI"socket.close ;TI" ;TI",# In another script, start this second ;TI"require 'socket' ;TI"include Socket::Constants ;TI"2socket = Socket.new(AF_INET, SOCK_STREAM, 0) ;TI"6sockaddr = Socket.sockaddr_in(2200, 'localhost') ;TI"socket.connect(sockaddr) ;TI"(socket.puts "Hello from script 2." ;TI"8puts "The server said, '#{socket.readline.chomp}'" ;TI"socket.close ;T:@format0o; ; [I"NRefer to Socket#accept for the exceptions that may be thrown if the call ;TI" to _accept_nonblock_ fails.;T@o; ; [I"TSocket#accept_nonblock may raise any error corresponding to accept(2) failure, ;TI""including Errno::EWOULDBLOCK.;T@o; ; [I"aIf the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED or Errno::EPROTO, ;TI")it is extended by IO::WaitReadable. ;TI"[So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock.;T@S;; i;I"See;To:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"Socket#accept;T: @fileI"ext/socket/socket.c;T:0@omit_headings_from_table_of_contents_below0I"@socket.accept_nonblock => [client_socket, client_addrinfo] ;T0[ I"();T@GFI"Socket;TcRDoc::NormalClass00