packets
Packets is a small library that makes writing packet-based TCP servers and clients a bit easier.
Creating a Server
use *;
use *;
use SocketAddr;
// Bind the server to localhost at port 60000.
let mut server = bind.unwrap;
// Accept all incoming connections.
server.accept_all;
// Receive all incoming packets, using String as our packet type.
let packets: = server.receive_all.unwrap;
for in packets
// Close all connections to the server and consume the Server object.
server.shutdown;
Creating a Client
use *;
use *;
let mut client = connect;
// Receive all incoming packets.
// In this example we use String as our Packet type.
let packets: = client.receive_all;
// Send a packet to the server, using String as our packet type for this example.
client.send;
// Shut this client down, consuming it.
client.shutdown;