class SFML::Network::Packet

Binary serializer with explicit, typed read/write — wire-compatible with SFML’s sf::Packet. Used by Tcp/UdpSocket’s send_packet /receive_packet (the network layer prepends a 4-byte length header for TCP framing, so the receiver always gets a whole packet).

All read calls consume bytes in FIFO order. After a write you can always re-read by sending the packet over the wire; the local read position only advances on the receive side. To rewind a locally-built packet, just construct a new one.

pkt = SFML::Network::Packet.new pkt.write_int32(42) pkt.write_string(“hello”) pkt.write_float(0.5)

# … send over a TcpSocket, receive on the other end …

incoming.read_int32 #=> 42 incoming.read_string #=> “hello” incoming.read_float #=> 0.5