D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Socket
/
Filename :
tcp-c.ri
back
Copy
U:RDoc::AnyMethod[iI"tcp:ETI"Socket::tcp;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"Ecreates a new socket object connected to host:port using TCP/IP.;To:RDoc::Markup::BlankLine o; ; [I"CStarting from Ruby 3.4, this method operates according to the ;TI"ZHappy Eyeballs Version 2 ({RFC 8305}[https://datatracker.ietf.org/doc/html/rfc8305]) ;TI"algorithm by default.;T@o; ; [I".For details on Happy Eyeballs Version 2, ;TI"Isee {Socket.tcp_fast_fallback=}[rdoc-ref:Socket.tcp_fast_fallback=].;T@o; ; [ I"<To make it behave the same as in Ruby 3.3 and earlier, ;TI"8explicitly specify the option fast_fallback:false. ;TI"=Or, setting Socket.tcp_fast_fallback=false will disable ;TI"SHappy Eyeballs Version 2 not only for this method but for all Socket globally.;T@o; ; [I"(If local_host:local_port is given, ;TI"the socket is bound to it.;T@o; ; [I"IThe optional last argument _opts_ is options represented by a hash. ;TI"'_opts_ may have following options:;T@o:RDoc::Markup::List: @type: LABEL:@items[o:RDoc::Markup::ListItem:@label[I":resolv_timeout;T; [o; ; [I"OSpecifies the timeout in seconds from when the hostname resolution starts.;To;;[I":connect_timeout;T; [o; ; [I"�This method sequentially attempts connecting to all candidate destination addresses.<br>The +connect_timeout+ specifies the timeout in seconds from the start of the connection attempt to the last candidate.<br>By default, all connection attempts continue until the timeout occurs.<br>When +fast_fallback:false+ is explicitly specified,<br>a timeout is set for each connection attempt and any connection attempt that exceeds its timeout will be canceled.;To;;[I":fast_fallback;T; [o; ; [I"IEnables the Happy Eyeballs Version 2 algorithm (enabled by default).;T@o; ; [I"?If a block is given, the block is called with the socket. ;TI")The value of the block is returned. ;TI"3The socket is closed when this method returns.;T@o; ; [I"2If no block is given, the socket is returned.;T@o:RDoc::Markup::Verbatim; [ I"1Socket.tcp("www.ruby-lang.org", 80) {|sock| ;TI"F sock.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n" ;TI" sock.close_write ;TI" puts sock.read ;TI"};T:@format0: @fileI"ext/socket/lib/socket.rb;T:0@omit_headings_from_table_of_contents_below0I"�Socket.tcp(host, port, local_host=nil, local_port=nil, [opts]) {|socket| ... } Socket.tcp(host, port, local_host=nil, local_port=nil, [opts]) ;TI"socket;T[ I"�(host, port, local_host = nil, local_port = nil, connect_timeout: nil, resolv_timeout: nil, fast_fallback: tcp_fast_fallback, &);T@LFI"Socket;TcRDoc::NormalClass00