Repository navigation
fix(driver,net)!: to/from/msg have optional address - #721
Conversation
BREAKING CHANGE: Socket::recv_{from,msg*}(), send_msg* now has optional
address as well as corresponding driver OpCodes
6a9ac8c to
6376477
Compare
There was a problem hiding this comment.
Pull request overview
Updates internal socket send/recv APIs to represent “no address” as Option<SockAddr> (instead of a zero-length SockAddr), aligning semantics across drivers and simplifying call sites (notably for TCP / connected sockets).
Changes:
- Change
Socket::{recv_from, recv_from_vectored, recv_msg, recv_msg_vectored}to returnOption<SockAddr>for the peer address. - Change
Socket::{send_msg, send_msg_vectored}to acceptOption<&SockAddr>and propagate this through driver ops. - Update
UdpSocketwrappers to unwrap the now-optional address (UDP expects an address on receive) and passSome(addr)on send.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| compio-net/src/udp.rs | Adapts UDP recv wrappers to unwrap Option<SockAddr> and updates send_msg calls to pass Some(&SockAddr) |
| compio-net/src/socket.rs | Changes internal Socket recv APIs to return optional address and send_msg APIs to accept optional address |
| compio-driver/src/sys/unix_op.rs | Updates Unix SendMsg op to store Option<SockAddr> and conditionally populate msghdr name fields |
| compio-driver/src/sys/iocp/op.rs | Updates IOCP SendMsg op to store Option<SockAddr> and populate WSAMSG name fields conditionally |
| compio-driver/src/op.rs | Maps recv results to Option<SockAddr> based on addr_size > 0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7ab07db to
51123fe
Compare
|
Should |
No? Because the
I was thinking like, You could argue that, documentation is enough and one should only use |
|
Thanks @fantix , and I get your point. It's fair enough. However, I still don't like the |
Yeah... I prefer explicit over implicit, so I vote for |
|
Please also suggest on the API design of the But this somehow doesn't feel right to me. UPDATE: ahh I think I should just rename #717 to |
BREAKING CHANGE: the following
OpCodeAPIs have changed in this proposal:RecvFrom(usize, SockAddr)(usize, Option<SockAddr>)RecvFromVectored(usize, SockAddr)(usize, Option<SockAddr>)RecvMsg(usize, usize, SockAddr)(usize, usize, Option<SockAddr>)as well as
RecvFromManaged, and:SendTo(FD, BUFFER, SockAddr, i32)SendToVectored(FD, BUFFER, SockAddr, i32)SendMsg(FD, BUFFER, CONTROL, SockAddr, i32)(FD, BUFFER, CONTROL, Option<SockAddr>, i32)Internal Socket APIs are also affected accordingly.
For example,
recv_msg()on a TCP socket was previously returning asocket2::SockAddrwithlen() == 0:This proposal elevates that to a semantic
Option<SockAddr>.On the sending end, this proposal simplifies this:
into just:
Refs #717