Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ztlpn/netmsg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An event loop and a simple messaging layer over TCP sockets. This is a toy project created with educational purposes. It is not intended for general use.

Example

Bind to an address, send and receive a message:

let addr_table = AddressTable([
    (NodeId(0xdeadbeef), "127.0.0.1:2000"),
    (NodeId(0xfeedface), "127.0.0.1:2001"),
].iter().map(|(id, addr)| (*id, addr.parse().unwrap())).collect());

let node = NetworkNode::bind(NodeId(0xdeadbeef), addr_table).unwrap();

node.send(NodeId(0xfeedface), b"hello", None).unwrap();

let msg = node.recv(None).unwrap();
println!("recv msg: {} from {}", String::from_utf8(msg.payload).unwrap(), msg.peer_id);

About

A toy messaging layer on top of tcp

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages