pub struct Kcp<Output> {
pub output: KcpOutput<Output>,
/* private fields */
}Expand description
KCP control
Fields§
§output: KcpOutput<Output>Implementations§
Source§impl<Output> Kcp<Output>
impl<Output> Kcp<Output>
Sourcepub fn new(conv: u32, token: u32, output: Output) -> Self
pub fn new(conv: u32, token: u32, output: Output) -> Self
Creates a KCP control object, conv must be equal in both endpoints in one connection.
output is the callback object for writing.
conv represents conversation.
Sourcepub fn new_stream(conv: u32, token: u32, output: Output) -> Self
pub fn new_stream(conv: u32, token: u32, output: Output) -> Self
Creates a KCP control object in stream mode, conv must be equal in both endpoints in one connection.
output is the callback object for writing.
conv represents conversation.
pub fn move_buf(&mut self)
Sourcepub fn input_conv(&mut self)
pub fn input_conv(&mut self)
Get conv from the next input call
Sourcepub fn waiting_conv(&self) -> bool
pub fn waiting_conv(&self) -> bool
Check if Kcp is waiting for the next input
Sourcepub fn input(&mut self, buf: &[u8]) -> KcpResult<usize>
pub fn input(&mut self, buf: &[u8]) -> KcpResult<usize>
Call this when you received a packet from raw connection
Sourcepub fn check(&self, current: u32) -> u32
pub fn check(&self, current: u32) -> u32
Determine when you should call update.
Return when you should invoke update in millisec, if there is no input/send calling.
You can call update in that time without calling it repeatly.
Sourcepub fn set_mtu(&mut self, mtu: usize) -> KcpResult<()>
pub fn set_mtu(&mut self, mtu: usize) -> KcpResult<()>
Change MTU size, default is 1400
MTU = Maximum Transmission Unit
Sourcepub fn set_interval(&mut self, interval: u32)
pub fn set_interval(&mut self, interval: u32)
Set check interval
Sourcepub fn set_nodelay(
&mut self,
nodelay: bool,
interval: i32,
resend: i32,
nc: bool,
)
pub fn set_nodelay( &mut self, nodelay: bool, interval: i32, resend: i32, nc: bool, )
Set nodelay
fastest config: nodelay(true, 20, 2, true)
nodelay: default is disable (false)
interval: internal update timer interval in millisec, default is 100ms
resend: 0:disable fast resend(default), 1:enable fast resend
nc: false: normal congestion control(default), true: disable congestion control
Sourcepub fn set_wndsize(&mut self, sndwnd: u16, rcvwnd: u16)
pub fn set_wndsize(&mut self, sndwnd: u16, rcvwnd: u16)
Set wndsize
set maximum window size: sndwnd=32, rcvwnd=32 by default
Sourcepub fn set_rx_minrto(&mut self, rto: u32)
pub fn set_rx_minrto(&mut self, rto: u32)
Set rx_minrto
Sourcepub fn set_fast_resend(&mut self, fr: u32)
pub fn set_fast_resend(&mut self, fr: u32)
Set fastresend
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
KCP header size
Sourcepub fn set_maximum_resend_times(&mut self, dead_link: u32)
pub fn set_maximum_resend_times(&mut self, dead_link: u32)
Set maximum resend times
Sourcepub fn is_dead_link(&self) -> bool
pub fn is_dead_link(&self) -> bool
Check if KCP connection is dead (resend times excceeded)