Sha256: 66ddc17365d026d59c0aa074e4b62af86917cefd89f3ae86e4fae13a4d967ab6

Contents?: true

Size: 815 Bytes

Versions: 52

Compression:

Stored size: 815 Bytes

Contents

# wxRuby2 Sample Code. Copyright (c) 2007-???? Mario J. Steele
# Freely reusable code: see SAMPLES-LICENSE.TXT for details

class Socket
  # Socket#recv_packet() 
  #
  # This method retrives 1kb of data from the socket.  It uses
  # IO#readpartial due to the fact, that IO#read() uses buffered IO,
  # which can cause errors.  Where as the IO#readpartial() will read up
  # to the maximum of 1024 bytes from the socket, and return what it
  # retrives.
  def recv_packet()
    self.readpartial(1024)
  end
  
  # Socket#send_packet()
  #
  # This method will send the packet, and ensure that a LF (0x0A) is at
  # the end of the data to be sent, as this is used as the determination
  # of the end of a packet.
  def send_packet(msg)
    if !msg.index("\n")
      msg += "\n"
    end
    self.write(msg)
  end
end

Version data entries

52 entries across 52 versions & 3 rubygems

Version Path
wxruby64-2.0.1-x64-mingw32 samples/sockets/SocketPackets.rb
wxruby-ruby19-2.0.1-x86-mingw32 samples/sockets/SocketPackets.rb
wxruby-ruby19-2.0.1-x86-linux samples/sockets/SocketPackets.rb
wxruby-ruby19-2.0.1-x86-darwin-9 samples/sockets/SocketPackets.rb
wxruby-2.0.1-x86-mswin32-60 samples/sockets/SocketPackets.rb
wxruby-2.0.1-x86-mingw32 samples/sockets/SocketPackets.rb
wxruby-2.0.1-x86-linux samples/sockets/SocketPackets.rb
wxruby-2.0.1-universal-darwin-9 samples/sockets/SocketPackets.rb
wxruby-1.9.7-i386-mswin32 samples/sockets/SocketPackets.rb
wxruby-1.9.5-i386-mswin32 samples/sockets/SocketPackets.rb
wxruby-1.9.4-i386-mswin32 samples/sockets/SocketPackets.rb
wxruby-1.9.3-i386-mswin32 samples/sockets/SocketPackets.rb
wxruby-1.9.10-universal-darwin-9 samples/sockets/SocketPackets.rb
wxruby-1.9.10-x86-linux samples/sockets/SocketPackets.rb
wxruby-1.9.10-x86_64-linux samples/sockets/SocketPackets.rb
wxruby-1.9.10-x86-mswin32-60 samples/sockets/SocketPackets.rb
wxruby-1.9.10-x86-mingw32 samples/sockets/SocketPackets.rb
wxruby-1.9.3-universal-darwin samples/sockets/SocketPackets.rb
wxruby-1.9.3-x86-linux samples/sockets/SocketPackets.rb
wxruby-1.9.4-x86_64-linux samples/sockets/SocketPackets.rb