Class: Nonnative::SocketPair
- Inherits:
-
Object
- Object
- Nonnative::SocketPair
- Defined in:
- lib/nonnative/socket_pair.rb
Direct Known Subclasses
Instance Method Summary collapse
- #connect(local_socket) ⇒ Object
-
#initialize(proxy) ⇒ SocketPair
constructor
A new instance of SocketPair.
Constructor Details
#initialize(proxy) ⇒ SocketPair
Returns a new instance of SocketPair.
5 6 7 |
# File 'lib/nonnative/socket_pair.rb', line 5 def initialize(proxy) @proxy = proxy end |
Instance Method Details
#connect(local_socket) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nonnative/socket_pair.rb', line 9 def connect(local_socket) remote_socket = create_remote_socket loop do ready = select([local_socket, remote_socket], nil, nil) break if pipe(ready, local_socket, remote_socket) break if pipe(ready, remote_socket, local_socket) end ensure local_socket.close remote_socket&.close end |