[][src]Module networking::sllp

provides access to Sllp (Secure Low Latency Protocol) Socket and Stream, and is intended for high volume low precision operations such as streaming note that this module has no syncronous implementation

Client Example

This example is not tested
use networking::sllp::SllpSocket;
use networking::test_config;
use networking::Layer3Addr;
use std::error::Error;
use networking::asyncronous::{AsyncSend, AsyncNetworkHost};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let (mut peer, config) = test_config();
    let socket = SllpSocket::from_host_config(&config).await?;
    // this needs to be updated to remote peer, because two devices cannot bind to the smae address
    peer.set_socket_addr((Layer3Addr::newv4(127, 0, 0, 1), 6464).into());
    let mut stream = socket.connect(&peer).await;
    loop { stream.send(b"hello world").await.unwrap(); }
    Ok(())
}

Server Example

This example is not tested
use networking::sllp::SllpSocket;
use networking::test_config;
use std::error::Error;
use networking::asyncronous::{AsyncRecv, AsyncNetworkHost};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let (peer, config) = test_config();
    let mut socket = SllpSocket::from_host_config(&config).await?;
    while let Some(strm) = socket.incoming().await {
        let mut stream = strm?.verify(&peer)?;
        tokio::spawn(async move {
            println!("new connection");
            loop {
                let mut invec = Vec::new();
                stream.recv(&mut invec).await.unwrap();
                println!(
                    "got message {}, from server",
                    String::from_utf8(invec).unwrap()
                );
            }
        });
    }
    Ok(())
}

Structs

OwnedIncoming
OwnedOutgoing
OwnedSllpReceiver
OwnedSllpSender

owned half of SllpSender

SllpIncoming

incoming half of SllpSocket allows for listening for new connections but not opening new connections

SllpOutgoing

outgoing half of SllpSocket allows for opening connections, but not listening for new ones

SllpReceiver

send half of SllpStream

SllpSender

send half of SllpStream

SllpSocket

this structure provides an alternative to TCP Networking, but is not connectionless while this structure uses an owned UdpSocket for networking, it also maintains a connection through the standard means that this crate provides this is offered as a way to increase the efficiency of the network of TCP at the cost of a lack of garuntee of packet order future implementations may implement a system of dropping out dated packets

SllpStream

this represents a UDP connection to a peer. while that may seem oxymoronic, in practice, implementing a structure this way allows for a finer grain of what data transfer methods are nessisary, as this crate implements high security, an increase in efficiency wouldn't rely on lack of connection, instead, the connection is maintained, and the efficiency gain comes from the lack of packet ordering, and extraneous network transmissions

Streams

a type alias, more or less for Arc<Mutex<HashMap<SocketAddr, Sender>>>

Type Definitions

IncomingMsg

messages sent from the socket to the main program use this format

NewConnection
OutgoingMsg

messages sent from main to the socket use this format