HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/share/ri/3.0.0/system/Socket/tcp_server_loop-c.ri
U:RDoc::AnyMethod[iI"tcp_server_loop:ETI"Socket::tcp_server_loop;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"Ycreates a TCP/IP server on _port_ and calls the block for each connection accepted. ;TI"RThe block is called with a socket and a client_address as an Addrinfo object.;To:RDoc::Markup::BlankLineo;
;	[I"VIf _host_ is specified, it is used with _port_ to determine the server addresses.;T@o;
;	[I"8The socket is *not* closed when the block returns. ;TI"/So application should close it explicitly.;T@o;
;	[I"/This method calls the block sequentially. ;TI"PIt means that the next connection is not accepted until the block returns. ;TI"gSo concurrent mechanism, thread for example, should be used to service multiple clients at a time.;T@o;
;	[
I"VNote that Addrinfo.getaddrinfo is used to determine the server socket addresses. ;TI">When Addrinfo.getaddrinfo returns two or more addresses, ;TI"(IPv4 and IPv6 address for example, ;TI"all of them are used. ;TI"HSocket.tcp_server_loop succeeds if one socket can be used at least.;T@o:RDoc::Markup::Verbatim;	[I"# Sequential echo server.
;TI".# It services only one client at a time.
;TI"<Socket.tcp_server_loop(16807) {|sock, client_addrinfo|
;TI"
  begin
;TI"$    IO.copy_stream(sock, sock)
;TI"  ensure
;TI"    sock.close
;TI"  end
;TI"}
;TI"
;TI"# Threaded echo server
;TI"/# It services multiple clients at a time.
;TI"5# Note that it may accept connections too much.
;TI"<Socket.tcp_server_loop(16807) {|sock, client_addrinfo|
;TI"  Thread.new {
;TI"    begin
;TI"&      IO.copy_stream(sock, sock)
;TI"    ensure
;TI"      sock.close
;TI"
    end
;TI"	  }
;TI"};T:@format0:
@fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below00I"socket, client_addrinfo;T[I"(host=nil, port);T@;FI"Socket;TcRDoc::NormalClass00