Skip to content

Conversation

suryaprakash0010
Copy link

This PR implements the missing getsockname() function.

Changes:

  • Added getsockname() to LibOS interface
  • Implemented support in SharedNetworkQueue to retrieve local socket address
  • Updated demi_getsockname() C binding with validation, buffer checks, and error handling
  • Ensured consistency with existing getpeername() implementation

Key Points:

  • Memory safety ensured with proper pointer and buffer handling
  • Error handling follows Demikernel conventions (EINVAL, ENOTCONN, ENOTSUP)
  • Supports IPv4 (consistent with current design)
  • Includes debug tracing for troubleshooting

Fixes #72

@suryaprakash0010
Copy link
Author

@microsoft-github-policy-service agree

@iyzhang
Copy link
Contributor

iyzhang commented Sep 25, 2025

This looks good to me! Would you please add some tests to /tests/rust/tcp and /tests/rust/tcp.rs so that we check the socket name every time that we bind.

pub fn getsockname(&mut self) -> Result<SocketAddrV4, Fail> {
match self.local() {
Some(addr) => {
// We only support IPv4 addresses in demikernel
Copy link
Contributor

@anandbonde anandbonde Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can be removed, the err msg makes it clear that we don't support IPv6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pdpix] Provide an Implementation for getsockname()
3 participants