Skip to content

Experimental, secure, p2p-oriented, transport-layer protocol

License

Notifications You must be signed in to change notification settings

franklee26/bluefin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bluefin

Bluefin is an experimental, P2P, transport-layer protocol. Unlike TCP, Bluefin runs in user-space and can allow for faster development cycles, greater flexibility in new features and more performant resource management compared to kernel-space implementations. Bluefin is currently only supported on MacOs and Linux.

Latest Version Documentation Github Workflow License: MIT codecov

Example

Pack-leader

#[tokio::main]
async fn main() -> BluefinResult<()> {
    let mut server = BluefinServer::new(std::net::SocketAddr::V4(SocketAddrV4::new(
        Ipv4Addr::new(192, 168, 1, 38),
        1235,
    )));
    server.bind().await?;

    while let Ok(conn) = s.accept().await {
        let _ = spawn(async move {
            let mut recv_bytes = [0u8; 1024];
            loop {
                let size = conn.recv(&mut recv_bytes, 1024).await.unwrap();

                println!(
                    "({:x}_{:x}) >>> Received: {:?}",
                    conn.src_conn_id,
                    conn.dst_conn_id,
                    &recv_bytes[..size],
                );
            }
        });
    }

    // The spawned tasks are looping forever. This infinite loop will keep the
    // process up forever.
    loop {}
}

Client

#[tokio::main]
async fn main() -> BluefinResult<()> {
    let mut client = BluefinClient::new(std::net::SocketAddr::V4(SocketAddrV4::new(
        Ipv4Addr::new(192, 168, 1, 38),
        1234,
    )));
    let mut conn = client
        .connect(std::net::SocketAddr::V4(SocketAddrV4::new(
            Ipv4Addr::new(192, 168, 1, 38),
            1235,
        )))
        .await?;

    let bytes = [1, 2, 3, 4];
    let size = conn.send(&bytes);
    println!("Sent {} bytes", size);

    Ok(())
}

About

Experimental, secure, p2p-oriented, transport-layer protocol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages