Class: TCPSocket

Inherits:
Object show all
Defined in:
lib/nyara/patches/tcp_socket.rb

Overview

patch TCPSocket to make operations synchrony

Instance Method Summary collapse

Constructor Details

#initialize(*xs) ⇒ TCPSocket

Returns a new instance of TCPSocket.


5
6
7
8
9
# File 'lib/nyara/patches/tcp_socket.rb', line 5

def initialize *xs
  _orig_initialize *xs
  Nyara::Ext.set_nonblock fileno
  Nyara::Ext.fd_watch fileno
end

Instance Method Details

#_orig_initializeObject


3
# File 'lib/nyara/patches/tcp_socket.rb', line 3

alias _orig_initialize initialize

#recv(max_len, flags = 0) ⇒ Object


19
20
21
# File 'lib/nyara/patches/tcp_socket.rb', line 19

def recv max_len, flags=0
  Nyara::Ext.fd_recv fileno, max_len, flags
end

#send(data, flags, dest_addr = nil, &blk) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/nyara/patches/tcp_socket.rb', line 11

def send data, flags, dest_addr=nil, &blk
  if dest_addr
    super
  else
    Nyara::Ext.fd_send fileno, data, flags, &blk
  end
end