[Bug Report] wrong of fn write in the TcpSocketState
dingiso opened this issue · 2 comments
dingiso commented
I think there are something wrong within the fn write
in the TcpSocketState, Code below:
fn write(&self, data: &[u8], _sendto_endpoint: Option<Endpoint>) -> SysResult {
// get the lock and handle of the global SOCKETS
let mut sockets = SOCKETS.lock();
let mut socket = sockets.get::<TcpSocket>(self.handle.0);
if socket.is_open() {
if socket.can_send() {
match socket.send_slice(&data) {
Ok(size) => {
// avoid deadlock
drop(socket);
drop(sockets);
poll_ifaces();
Ok(size)
}
Err(_) => Err(SysError::ENOBUFS),
}
} else {
Err(SysError::ENOBUFS)
}
} else {
Err(SysError::ENOTCONN)
}
}
Withourt using the second parameter _sendto_endpoint
I'm considering that there maybe some problems , the parameter is not necessary , tcp first bind
and connect
with a endpoint which ensure the data transfer to the endpoint
jiegec commented
I'm considering that there maybe some problems , the parameter is not necessary , tcp first bind and connect with a endpoint which ensure the data transfer to the endpoint
That's why the endpoint parameter is not used. It is saved in socket. The endpoint is here because the trait requires it, and UDP uses that.
dingiso commented
Thank you , I understand it !!