Struct kcp::Kcp [−][src]
pub struct Kcp<Output: Write> { /* fields omitted */ }
KCP control
Methods
impl<Output: Write> Kcp<Output>
[src]
impl<Output: Write> Kcp<Output>
pub fn new(conv: u32, output: Output) -> Self
[src]
pub fn new(conv: 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.
pub fn new_stream(conv: u32, output: Output) -> Self
[src]
pub fn new_stream(conv: 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 peeksize(&self) -> KcpResult<usize>
[src]
pub fn peeksize(&self) -> KcpResult<usize>
Check buffer size without actually consuming it
pub fn recv(&mut self, buf: &mut [u8]) -> KcpResult<usize>
[src]
pub fn recv(&mut self, buf: &mut [u8]) -> KcpResult<usize>
Receive data from buffer
pub fn send(&mut self, buf: &[u8]) -> KcpResult<usize>
[src]
pub fn send(&mut self, buf: &[u8]) -> KcpResult<usize>
Send bytes into buffer
pub fn input_conv(&mut self)
[src]
pub fn input_conv(&mut self)
Get conv
from the next input
call
pub fn waiting_conv(&self) -> bool
[src]
pub fn waiting_conv(&self) -> bool
Check if Kcp is waiting for the next input
pub fn set_conv(&mut self, conv: u32)
[src]
pub fn set_conv(&mut self, conv: u32)
Set conv
value
pub fn conv(&self) -> u32
[src]
pub fn conv(&self) -> u32
Get conv
pub fn input(&mut self, buf: &[u8]) -> KcpResult<usize>
[src]
pub fn input(&mut self, buf: &[u8]) -> KcpResult<usize>
Call this when you received a packet from raw connection
pub fn flush_ack(&mut self) -> KcpResult<()>
[src]
pub fn flush_ack(&mut self) -> KcpResult<()>
Flush pending ACKs
pub fn flush(&mut self) -> KcpResult<()>
[src]
pub fn flush(&mut self) -> KcpResult<()>
Flush pending data in buffer.
pub fn update(&mut self, current: u32) -> KcpResult<()>
[src]
pub fn update(&mut self, current: u32) -> KcpResult<()>
Update state every 10ms ~ 100ms.
Or you can ask check
when to call this again.
pub fn check(&self, current: u32) -> u32
[src]
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.
pub fn set_mtu(&mut self, mtu: usize) -> KcpResult<()>
[src]
pub fn set_mtu(&mut self, mtu: usize) -> KcpResult<()>
Change MTU size, default is 1400
MTU = Maximum Transmission Unit
pub fn mtu(&self) -> usize
[src]
pub fn mtu(&self) -> usize
Get MTU
pub fn set_interval(&mut self, interval: u32)
[src]
pub fn set_interval(&mut self, interval: u32)
Set check interval
pub fn set_nodelay(
&mut self,
nodelay: bool,
interval: i32,
resend: i32,
nc: bool
)
[src]
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
pub fn set_wndsize(&mut self, sndwnd: u16, rcvwnd: u16)
[src]
pub fn set_wndsize(&mut self, sndwnd: u16, rcvwnd: u16)
Set wndsize
set maximum window size: sndwnd=32
, rcvwnd=32
by default
pub fn snd_wnd(&self) -> u16
[src]
pub fn snd_wnd(&self) -> u16
snd_wnd
Send window
pub fn rcv_wnd(&self) -> u16
[src]
pub fn rcv_wnd(&self) -> u16
rcv_wnd
Receive window
pub fn wait_snd(&self) -> usize
[src]
pub fn wait_snd(&self) -> usize
Get waitsnd
, how many packet is waiting to be sent
pub fn set_rx_minrto(&mut self, rto: u32)
[src]
pub fn set_rx_minrto(&mut self, rto: u32)
Set rx_minrto
pub fn set_fast_resend(&mut self, fr: u32)
[src]
pub fn set_fast_resend(&mut self, fr: u32)
Set fastresend
pub fn header_len() -> usize
[src]
pub fn header_len() -> usize
KCP header size
pub fn is_stream(&self) -> bool
[src]
pub fn is_stream(&self) -> bool
Enabled stream or not
pub fn mss(&self) -> u32
[src]
pub fn mss(&self) -> u32
Maximum Segment Size
pub fn set_maximum_resend_times(&mut self, dead_link: u32)
[src]
pub fn set_maximum_resend_times(&mut self, dead_link: u32)
Set maximum resend times
pub fn is_dead_link(&self) -> bool
[src]
pub fn is_dead_link(&self) -> bool
Check if KCP connection is dead (resend times excceeded)