PATH:
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Socket
U:RDoc::AnyMethod[iI"connect:ETI"Socket#connect;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"SRequests a connection to be made on the given +remote_sockaddr+. Returns 0 if ;TI"2successful, otherwise an exception is raised.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI"Parameter;To:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"W+remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object;T@S;; i;I" Example:;To:RDoc::Markup::Verbatim; [ I"## Pull down Google's web page ;TI"require 'socket' ;TI"include Socket::Constants ;TI"4socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) ;TI"@sockaddr = Socket.pack_sockaddr_in( 80, 'www.google.com' ) ;TI" socket.connect( sockaddr ) ;TI".socket.write( "GET / HTTP/1.0\r\n\r\n" ) ;TI"results = socket.read ;T:@format0S;; i;I"Unix-based Exceptions;To; ; [I"LOn unix-based systems the following system exceptions may be raised if ;TI"!the call to _connect_ fails:;To;;;;[o;;0; [o; ; [I"OErrno::EACCES - search permission is denied for a component of the prefix ;TI"3path or write access to the +socket+ is denied;To;;0; [o; ; [I"9Errno::EADDRINUSE - the _sockaddr_ is already in use;To;;0; [o; ; [I"OErrno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the ;TI"local machine;To;;0; [o; ; [I"OErrno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for ;TI"1the address family of the specified +socket+;To;;0; [o; ; [I"MErrno::EALREADY - a connection is already in progress for the specified ;TI"socket;To;;0; [o; ; [I"?Errno::EBADF - the +socket+ is not a valid file descriptor;To;;0; [o; ; [I"SErrno::ECONNREFUSED - the target _sockaddr_ was not listening for connections ;TI"#refused the connection request;To;;0; [o; ; [I"EErrno::ECONNRESET - the remote host reset the connection request;To;;0; [o; ; [I"6Errno::EFAULT - the _sockaddr_ cannot be accessed;To;;0; [o; ; [I"LErrno::EHOSTUNREACH - the destination host cannot be reached (probably ;TI"Abecause the host is down or a remote router cannot reach it);To;;0; [o; ; [I"IErrno::EINPROGRESS - the O_NONBLOCK is set for the +socket+ and the ;TI"Jconnection cannot be immediately established; the connection will be ;TI"established asynchronously;To;;0; [o; ; [I"OErrno::EINTR - the attempt to establish the connection was interrupted by ;TI"Ndelivery of a signal that was caught; the connection will be established ;TI"asynchronously;To;;0; [o; ; [I"AErrno::EISCONN - the specified +socket+ is already connected;To;;0; [o; ; [I"OErrno::EINVAL - the address length used for the _sockaddr_ is not a valid ;TI"Nlength for the address family or there is an invalid family in _sockaddr_;To;;0; [o; ; [I"MErrno::ENAMETOOLONG - the pathname resolved had a length which exceeded ;TI" PATH_MAX;To;;0; [o; ; [I"PErrno::ENETDOWN - the local interface used to reach the destination is down;To;;0; [o; ; [I"<Errno::ENETUNREACH - no route to the network is present;To;;0; [o; ; [I"2Errno::ENOBUFS - no buffer space is available;To;;0; [o; ; [I"KErrno::ENOSR - there were insufficient STREAMS resources available to ;TI"complete the operation;To;;0; [o; ; [I"GErrno::ENOTSOCK - the +socket+ argument does not refer to a socket;To;;0; [o; ; [I"RErrno::EOPNOTSUPP - the calling +socket+ is listening and cannot be connected;To;;0; [o; ; [I"MErrno::EPROTOTYPE - the _sockaddr_ has a different type than the socket ;TI"(bound to the specified peer address;To;;0; [o; ; [I"MErrno::ETIMEDOUT - the attempt to connect timed out before a connection ;TI"was made.;T@o; ; [I"LOn unix-based systems if the address family of the calling +socket+ is ;TI"JAF_UNIX the follow exceptions may be raised if the call to _connect_ ;TI"fails:;To;;;;[ o;;0; [o; ; [I"MErrno::EIO - an i/o error occurred while reading from or writing to the ;TI"file system;To;;0; [o; ; [I"LErrno::ELOOP - too many symbolic links were encountered in translating ;TI"the pathname in _sockaddr_;To;;0; [o; ; [I"HErrno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX ;TI"Ccharacters, or an entire pathname exceeded PATH_MAX characters;To;;0; [o; ; [I"PErrno::ENOENT - a component of the pathname does not name an existing file ;TI"'or the pathname is an empty string;To;;0; [o; ; [I"SErrno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_ ;TI"is not a directory;T@S;; i;I"Windows Exceptions;To; ; [I"IOn Windows systems the following system exceptions may be raised if ;TI"!the call to _connect_ fails:;To;;;;[o;;0; [o; ; [I"*Errno::ENETDOWN - the network is down;To;;0; [o; ; [I"EErrno::EADDRINUSE - the socket's local address is already in use;To;;0; [o; ; [I",Errno::EINTR - the socket was cancelled;To;;0; [o; ; [I"SErrno::EINPROGRESS - a blocking socket is in progress or the service provider ;TI"Ois still processing a callback function. Or a nonblocking connect call is ;TI"!in progress on the +socket+.;To;;0; [o; ; [I"(Errno::EALREADY - see Errno::EINVAL;To;;0; [o; ; [I"OErrno::EADDRNOTAVAIL - the remote address is not a valid address, such as ;TI".ADDR_ANY TODO check ADDRANY TO INADDR_ANY;To;;0; [o; ; [I"QErrno::EAFNOSUPPORT - addresses in the specified family cannot be used with ;TI"with this +socket+;To;;0; [o; ; [I"SErrno::ECONNREFUSED - the target _sockaddr_ was not listening for connections ;TI"#refused the connection request;To;;0; [o; ; [I"OErrno::EFAULT - the socket's internal address or address length parameter ;TI"Bis too small or is not a valid part of the user space address;To;;0; [o; ; [I"7Errno::EINVAL - the +socket+ is a listening socket;To;;0; [o; ; [I"7Errno::EISCONN - the +socket+ is already connected;To;;0; [o; ; [I"SErrno::ENETUNREACH - the network cannot be reached from this host at this time;To;;0; [o; ; [I"=Errno::EHOSTUNREACH - no route to the network is present;To;;0; [o; ; [I"2Errno::ENOBUFS - no buffer space is available;To;;0; [o; ; [I"GErrno::ENOTSOCK - the +socket+ argument does not refer to a socket;To;;0; [o; ; [I"MErrno::ETIMEDOUT - the attempt to connect timed out before a connection ;TI"was made.;To;;0; [o; ; [I"FErrno::EWOULDBLOCK - the socket is marked as nonblocking and the ;TI"/connection cannot be completed immediately;To;;0; [o; ; [I"GErrno::EACCES - the attempt to connect the datagram socket to the ;TI"broadcast address failed;T@S;; i;I"See;To;;;;[o;;0; [o; ; [I"/connect manual pages on unix-based systems;To;;0; [o; ; [I"@connect function in Microsoft's Winsock functions reference;T: @fileI"ext/socket/socket.c;T:0@omit_headings_from_table_of_contents_below0I"*socket.connect(remote_sockaddr) => 0 ;T0[ I" (p1);T@HFI"Socket;TcRDoc::NormalClass00
[-] getifaddrs-c.ri
[edit]
[-] unpack_sockaddr_in-c.ri
[edit]
[-] tcp_without_fast_fallback-c.ri
[edit]
[-] pair-c.ri
[edit]
[-] udp_server_loop-c.ri
[edit]
[-] getservbyname-c.ri
[edit]
[-] udp_server_loop_on-c.ri
[edit]
[-] unix-c.ri
[edit]
[-] tcp_with_fast_fallback-c.ri
[edit]
[-] sockaddr_un-c.ri
[edit]
[-] cdesc-Socket.ri
[edit]
[-] ip_address%3f-c.ri
[edit]
[-] current_clock_time-c.ri
[edit]
[-] tcp-c.ri
[edit]
[-] udp_server_recv-c.ri
[edit]
[-] bind-i.ri
[edit]
[-] connect_nonblock-i.ri
[edit]
[-] socketpair-c.ri
[edit]
[-] unix_server_socket-c.ri
[edit]
[-] new-c.ri
[edit]
[-] gethostbyaddr-c.ri
[edit]
[-] accept-i.ri
[edit]
[-] udp_server_sockets-c.ri
[edit]
[-] getnameinfo-c.ri
[edit]
[-] sockaddr_in-c.ri
[edit]
[-] gethostname-c.ri
[edit]
[-] listen-i.ri
[edit]
[-] tcp_fast_fallback-c.ri
[edit]
[-] unpack_sockaddr_un-c.ri
[edit]
[-] recvfrom-i.ri
[edit]
[-] pack_sockaddr_in-c.ri
[edit]
[+]
UDPSource
[+]
AncillaryData
[+]
HostnameResolutionStore
[-] expired%3f-c.ri
[edit]
[-] unix_socket_abstract_name%3f-c.ri
[edit]
[-] tcp_server_loop-c.ri
[edit]
[-] sysaccept-i.ri
[edit]
[+]
Constants
[-] ipv6only%21-i.ri
[edit]
[-] ip_address_list-c.ri
[edit]
[+]
..
[-] second_to_timeout-c.ri
[edit]
[+]
Ifaddr
[-] pack_sockaddr_un-c.ri
[edit]
[-] accept_loop-c.ri
[edit]
[-] connect-i.ri
[edit]
[-] resolve_hostname-c.ri
[edit]
[+]
ResolutionError
[-] tcp_server_sockets-c.ri
[edit]
[-] unix_server_loop-c.ri
[edit]
[-] tcp_fast_fallback%3d-c.ri
[edit]
[-] gethostbyname-c.ri
[edit]
[-] accept_nonblock-i.ri
[edit]
[-] getservbyport-c.ri
[edit]
[+]
Option
[-] recvfrom_nonblock-i.ri
[edit]
[+]
HostnameResolutionResult
[-] getaddrinfo-c.ri
[edit]