Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia's getsockname is different from UNIX getsockname #21801

Closed
amitmurthy opened this issue May 11, 2017 · 0 comments
Closed

Julia's getsockname is different from UNIX getsockname #21801

amitmurthy opened this issue May 11, 2017 · 0 comments
Labels
io Involving the I/O subsystem: libuv, read, write, etc.

Comments

@amitmurthy
Copy link
Contributor

Julia's getsockname :

help?> getsockname
search: getsockname

  getsockname(sock::Union{TCPServer, TCPSocket}) -> (IPAddr, UInt16)

  Get the IP address and the port that the given TCPSocket is connected to (or bound to, in the case of TCPServer).

UNIX:

int
     getsockname(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len);

DESCRIPTION
     The getsockname() function returns the current address for the specified socket.
     int
     getpeername(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len);

DESCRIPTION
     The getpeername() function returns the address of the peer connected to the specified socket.

Julia's getsockname is equivalent to UNIX's getsockname for TCPServer. For TCPSocket it is equivalent to getpeername -

julia/base/socket.jl

Lines 847 to 855 in 1129de3

r = if isa(sock, TCPServer)
ccall(:jl_tcp_getsockname, Int32,
(Ptr{Void}, Ref{Cushort}, Ptr{Void}, Ref{Cuint}),
sock.handle, rport, raddress, rfamily)
else
ccall(:jl_tcp_getpeername, Int32,
(Ptr{Void}, Ref{Cushort}, Ptr{Void}, Ref{Cuint}),
sock.handle, rport, raddress, rfamily)
end

I suggest we mirror standard UNIX definitions and introduce a getpeername .

@kshyatt kshyatt added the io Involving the I/O subsystem: libuv, read, write, etc. label May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

No branches or pull requests

2 participants