Class: EaseEngine::UDPSocket
Instance Attribute Summary
Attributes inherited from Socket
#dst_addr, #err, #is_disable, #read_buf, #read_max_size, #socket, #write_buf
Instance Method Summary collapse
-
#initialize(*args) ⇒ UDPSocket
constructor
A new instance of UDPSocket.
- #recv(max, flags = 0) ⇒ Object
- #send(msg, flags, *args) ⇒ Object
Methods inherited from Socket
#bind, #close, #errno, #recvfrom, #to_i
Constructor Details
#initialize(*args) ⇒ UDPSocket
Returns a new instance of UDPSocket.
155 156 157 158 159 |
# File 'lib/ease_engine/socket.rb', line 155 def initialize( *args ) super @socket = ::UDPSocket.new end |
Instance Method Details
#recv(max, flags = 0) ⇒ Object
169 170 171 172 |
# File 'lib/ease_engine/socket.rb', line 169 def recv( max, flags = 0 ) buf, @dst_addr = recvfrom( max, flags ) buf end |
#send(msg, flags, *args) ⇒ Object
161 162 163 164 165 166 167 |
# File 'lib/ease_engine/socket.rb', line 161 def send( msg, flags, *args ) if args.empty? && ! @dst_addr.nil? super( msg, flags, @dst_addr[ 3 ], @dst_addr[ 1 ] ) else super( msg, flags, *args ) end end |