This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.

connect_nonblock

        # Socket.connect_nonblock

(from ruby core)
---
    socket.connect_nonblock(remote_sockaddr, [options]) => 0

---

Requests a connection to be made on the given `remote_sockaddr` after
O_NONBLOCK is set for the underlying file descriptor. Returns 0 if
successful, otherwise an exception is raised.

### Parameter
    # +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object

### Example:
    # Pull down Google's web page
    require 'socket'
    include Socket::Constants
    socket = Socket.new(AF_INET, SOCK_STREAM, 0)
    sockaddr = Socket.sockaddr_in(80, 'www.google.com')
    begin # emulate blocking connect
      socket.connect_nonblock(sockaddr)
    rescue IO::WaitWritable
      IO.select(nil, [socket]) # wait 3-way handshake completion
      begin
        socket.connect_nonblock(sockaddr) # check connection failure
      rescue Errno::EISCONN
      end
    end
    socket.write("GET / HTTP/1.0\r\n\r\n")
    results = socket.read

Refer to Socket#connect for the exceptions that may be thrown if the
call to *connect_nonblock* fails.

Socket#connect_nonblock may raise any error corresponding to connect(2)
failure, including Errno::EINPROGRESS.

If the exception is Errno::EINPROGRESS, it is extended by
IO::WaitWritable. So IO::WaitWritable can be used to rescue the
exceptions for retrying connect_nonblock.

By specifying a keyword argument *exception* to `false`, you can
indicate that connect_nonblock should not raise an IO::WaitWritable
exception, but return the symbol `:wait_writable` instead.

### See
    # Socket#connect



      

This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.