Class: Pitchfork::MessageSocket
- Inherits:
-
Object
- Object
- Pitchfork::MessageSocket
- Defined in:
- lib/pitchfork/message.rb
Defined Under Namespace
Classes: FD
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #close_read ⇒ Object
- #close_write ⇒ Object
-
#initialize(socket) ⇒ MessageSocket
constructor
A new instance of MessageSocket.
- #recvmsg_nonblock(exception: true) ⇒ Object
- #sendmsg(message) ⇒ Object
- #sendmsg_nonblock(message, exception: true) ⇒ Object
- #to_io ⇒ Object
- #wait(*args) ⇒ Object
Constructor Details
#initialize(socket) ⇒ MessageSocket
Returns a new instance of MessageSocket.
17 18 19 20 |
# File 'lib/pitchfork/message.rb', line 17 def initialize(socket) raise ArgumentError, "expected a socket, got: #{socket.inspect}" unless socket @socket = socket end |
Class Method Details
.ruby2_keywords(*args) ⇒ Object
9 10 11 |
# File 'lib/pitchfork/message.rb', line 9 def ruby2_keywords(*args) args end |
Instance Method Details
#close ⇒ Object
39 40 41 |
# File 'lib/pitchfork/message.rb', line 39 def close @socket.close end |
#close_read ⇒ Object
31 32 33 |
# File 'lib/pitchfork/message.rb', line 31 def close_read @socket.close_read end |
#close_write ⇒ Object
35 36 37 |
# File 'lib/pitchfork/message.rb', line 35 def close_write @socket.close_write end |
#recvmsg_nonblock(exception: true) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/pitchfork/message.rb', line 64 def recvmsg_nonblock(exception: true) case = @socket.recvmsg_nonblock(scm_rights: true, exception: exception) when Array () else end end |
#sendmsg(message) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/pitchfork/message.rb', line 43 def sendmsg() payload, ios = () @socket.sendmsg( payload, 0, nil, *ios.map { |io| Socket::AncillaryData.unix_rights(io) }, ) end |
#sendmsg_nonblock(message, exception: true) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pitchfork/message.rb', line 53 def sendmsg_nonblock(, exception: true) payload, ios = () @socket.sendmsg_nonblock( payload, 0, nil, *ios.map { |io| Socket::AncillaryData.unix_rights(io) }, exception: exception, ) end |
#to_io ⇒ Object
22 23 24 |
# File 'lib/pitchfork/message.rb', line 22 def to_io @socket end |
#wait(*args) ⇒ Object
26 27 28 |
# File 'lib/pitchfork/message.rb', line 26 def wait(*args) @socket.wait(*args) end |