Skip to content

Commit

Permalink
Merge pull request #2 from Josen-B/main
Browse files Browse the repository at this point in the history
TCP support SO_REUSEADDR
  • Loading branch information
scPointer authored Aug 11, 2024
2 parents b7134a3 + aa3b580 commit 553aab4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ pub struct Socket<'a> {
/// Address passed to listen(). Listen address is set when listen() is called and
/// used every time the socket is reset back to the LISTEN state.
listen_endpoint: IpListenEndpoint,
/// Address passed to bind(). Record the binding address of the socket.
bound_endpoint: IpListenEndpoint,
/// Current 4-tuple (local and remote endpoints).
tuple: Option<Tuple>,
/// The sequence number corresponding to the beginning of the transmit buffer.
Expand Down Expand Up @@ -521,6 +523,7 @@ impl<'a> Socket<'a> {
keep_alive: None,
hop_limit: None,
listen_endpoint: IpListenEndpoint::default(),
bound_endpoint: IpListenEndpoint::default(),
tuple: None,
local_seq_no: TcpSeqNumber::default(),
remote_seq_no: TcpSeqNumber::default(),
Expand Down Expand Up @@ -770,6 +773,18 @@ impl<'a> Socket<'a> {
Some(self.tuple?.remote)
}

/// get bound endpoint.
#[inline]
pub fn get_bound_endpoint(&self) -> IpListenEndpoint {
self.bound_endpoint
}

/// set bound endpoint.
#[inline]
pub fn set_bound_endpoint(&mut self, bound_endpoint: IpListenEndpoint) {
self.bound_endpoint = bound_endpoint
}

/// Return the connection state, in terms of the TCP state machine.
#[inline]
pub fn state(&self) -> State {
Expand Down

0 comments on commit 553aab4

Please sign in to comment.