Class: Socket

Inherits:
BasicSocket show all
Defined in:
lib/neverblock/io/socket.rb

Direct Known Subclasses

TCPSocket

Constant Summary

Constants inherited from IO

IO::NB_BUFFER_LENGTH

Instance Method Summary collapse

Methods inherited from BasicSocket

getaddress, #recv, #recv_blocking, #recv_neverblock

Methods inherited from IO

#getc, #gets, #print, #rb_getc, #rb_gets, #rb_print, #rb_read, #rb_readchar, #rb_readline, #rb_readlines, #rb_sysread, #rb_syswrite, #rb_write, #read, #read_neverblock, #readchar, #readline, #readlines, #readpartial, #sysread, #syswrite, #write, #write_neverblock

Instance Method Details

#connect(server_sockaddr) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/neverblock/io/socket.rb', line 57

def connect(server_sockaddr)
  if NB.neverblocking?
 	connect_neverblock(server_sockaddr)
  else
    connect_blocking(server_sockaddr)
  end
end

#connect_blockingObject



44
# File 'lib/neverblock/io/socket.rb', line 44

alias_method :connect_blocking, :connect

#connect_neverblock(server_sockaddr) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/neverblock/io/socket.rb', line 46

def connect_neverblock(server_sockaddr)
  begin
    connect_nonblock(server_sockaddr)
  rescue Errno::EINPROGRESS, Errno::EINTR, Errno::EALREADY, Errno::EWOULDBLOCK
    NB.wait(:write, self)
	retry
  rescue Errno::EISCONN
    # do nothing, we are good
  end
end