bevy_simple_networking icon indicating copy to clipboard operation
bevy_simple_networking copied to clipboard

tcp support

Open bacongobbler opened this issue 2 years ago • 0 comments

There should be a way to support TCP connections. At the moment, both the *_recv_packet_system and send_packet_system both rely on a UdpSocket resource being present. We could split this out as a trait:

pub trait Socket {
    fn recv(&self, &mut [u8]) -> io::Result<(usize, SocketAddr)>;
    fn send(&self, buf: &[u8], addr: SocketAddr) -> io::Result<usize>;
}

Then use the trait in both systems so that we can swap out a UdpSocket for a TcpListener.

bacongobbler avatar Oct 13 '21 15:10 bacongobbler