Class PacketIO
In: lib/network/packetio.rb
Parent: SockIO
PacketIO
SockIO
TopLevel

The PacketIO class implements a mechanism to send and recv packets delimited by a length prefix which is assumed to be a 4 bytes integer in network byte order.

Methods

new   read   write  

Public Class methods

Creates a new PackIO object

sock
The socket which will be used
bufsize
The size of the buffer to use (default is 16K)

Public Instance methods

read will receive a data from the socket.

return
The data read
IOError
A sockets error occurred.
EOFError
The connection has closed normally.

write will transmit a packet to the socket, we calculated the size here

msg
The message string to be sent.
return
false if more data to be written, true if all data written
IOError
A sockets error occurred.
EOFError
The connection has closed normally.

[Validate]