관리-도구
편집 파일: connect-i.yaml
--- !ruby/object:RI::MethodDescription aliases: [] block_params: comment: - !ruby/struct:SM::Flow::P body: Requests a connection to be made on the given <tt>server_sockaddr</tt>. Returns 0 if successful, otherwise an exception is raised. - !ruby/struct:SM::Flow::H level: 3 text: Parameter - !ruby/object:SM::Flow::LIST contents: - !ruby/struct:SM::Flow::LI label: "*" body: <tt>server_sockaddr</tt> - the <tt>struct</tt> sockaddr contained in a string type: :BULLET - !ruby/struct:SM::Flow::H level: 3 text: "Example:" - !ruby/struct:SM::Flow::VERB body: " # Pull down Google's web page\n require 'socket'\n include Socket::Constants\n socket = Socket.new( AF_INET, SOCK_STREAM, 0 )\n sockaddr = Socket.pack_sockaddr_in( 80, 'www.google.com' )\n socket.connect( sockaddr )\n socket.write( "GET / HTTP/1.0\\r\\n\\r\\n" )\n results = socket.read\n" - !ruby/struct:SM::Flow::H level: 3 text: Unix-based Exceptions - !ruby/struct:SM::Flow::P body: "On unix-based systems the following system exceptions may be raised if the call to <em>connect</em> fails:" - !ruby/object:SM::Flow::LIST contents: - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EACCES - search permission is denied for a component of the prefix path or write access to the <tt>socket</tt> is denided - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EADDRINUSE - the <em>sockaddr</em> is already in use - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EADDRNOTAVAIL - the specified <em>sockaddr</em> is not available from the local machine - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EAFNOSUPPORT - the specified <em>sockaddr</em> is not a valid address for the address family of the specified <tt>socket</tt> - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EALREADY - a connection is already in progress for the specified socket - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EBADF - the <tt>socket</tt> is not a valid file descriptor - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ECONNREFUSED - the target <em>sockaddr</em> was not listening for connections refused the connection request - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ECONNRESET - the remote host reset the connection request - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EFAULT - the <em>sockaddr</em> cannot be accessed - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EHOSTUNREACH - the destination host cannot be reached (probably because the host is down or a remote router cannot reach it) - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EINPROGRESS - the O_NONBLOCK is set for the <tt>socket</tt> and the connection cnanot be immediately established; the connection will be established asynchronously - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EINTR - the attempt to establish the connection was interrupted by delivery of a signal that was caught; the connection will be established asynchronously - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EISCONN - the specified <tt>socket</tt> is already connected - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EINVAL - the address length used for the <em>sockaddr</em> is not a valid length for the address family or there is an invalid family in <em>sockaddr</em> - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded PATH_MAX - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENETDOWN - the local interface used to reach the destination is down - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENETUNREACH - no route to the network is present - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENOBUFS - no buffer space is available - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENOSR - there were insufficient STREAMS resources available to complete the operation - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENOTSOCK - the <tt>socket</tt> argument does not refer to a socket - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EOPNOTSUPP - the calling <tt>socket</tt> is listening and cannot be connected - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EPROTOTYPE - the <em>sockaddr</em> has a different type than the socket bound to the specified peer address - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ETIMEDOUT - the attempt to connect time out before a connection was made. type: :BULLET - !ruby/struct:SM::Flow::P body: "On unix-based systems if the address family of the calling <tt>socket</tt> is AF_UNIX the follow exceptions may be raised if the call to <em>connect</em> fails:" - !ruby/object:SM::Flow::LIST contents: - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EIO - an i/o error occured while reading from or writing to the file system - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ELOOP - too many symbolic links were encountered in translating the pathname in <em>sockaddr</em> - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX characters, or an entired pathname exceeded PATH_MAX characters - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENOENT - a component of the pathname does not name an existing file or the pathname is an empty string - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENOTDIR - a component of the path prefix of the pathname in <em>sockaddr</em> is not a directory type: :BULLET - !ruby/struct:SM::Flow::H level: 3 text: Windows Exceptions - !ruby/struct:SM::Flow::P body: "On Windows systems the following system exceptions may be raised if the call to <em>connect</em> fails:" - !ruby/object:SM::Flow::LIST contents: - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENETDOWN - the network is down - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EADDRINUSE - the socket's local address is already in use - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EINTR - the socket was cancelled - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EINPROGRESS - a blocking socket is in progress or the service provider is still processing a callback function. Or a nonblocking connect call is in progress on the <tt>socket</tt>. - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EALREADY - see Errno::EINVAL - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EADDRNOTAVAIL - the remote address is not a valid address, such as ADDR_ANY TODO check ADDRANY TO INADDR_ANY - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EAFNOSUPPORT - addresses in the specified family cannot be used with with this <tt>socket</tt> - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ECONNREFUSED - the target <em>sockaddr</em> was not listening for connections refused the connection request - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EFAULT - the socket's internal address or address length parameter is too small or is not a valid part of the user space address - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EINVAL - the <tt>socket</tt> is a listening socket - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EISCONN - the <tt>socket</tt> is already connected - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENETUNREACH - the network cannot be reached from this host at this time - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EHOSTUNREACH - no route to the network is present - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENOBUFS - no buffer space is available - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ENOTSOCK - the <tt>socket</tt> argument does not refer to a socket - !ruby/struct:SM::Flow::LI label: "*" body: Errno::ETIMEDOUT - the attempt to connect time out before a connection was made. - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EWOULDBLOCK - the socket is marked as nonblocking and the connection cannot be completed immediately - !ruby/struct:SM::Flow::LI label: "*" body: Errno::EACCES - the attempt to connect the datagram socket to the broadcast address failed type: :BULLET - !ruby/struct:SM::Flow::H level: 3 text: See - !ruby/object:SM::Flow::LIST contents: - !ruby/struct:SM::Flow::LI label: "*" body: connect manual pages on unix-based systems - !ruby/struct:SM::Flow::LI label: "*" body: connect function in Microsoft's Winsock functions reference type: :BULLET full_name: Socket#connect is_singleton: false name: connect params: | socket.connect(server_sockaddr) => 0 visibility: public