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

add InetAddr constructor from string #31459

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add docs for InetAddr
Pietro Vertechi committed Apr 3, 2019
commit 1e6e0de08e8185945405a7663fdd76ee788a42db
27 changes: 27 additions & 0 deletions stdlib/Sockets/src/IPAddr.jl
Original file line number Diff line number Diff line change
@@ -271,7 +271,34 @@ struct InetAddr{T<:IPAddr}
port::UInt16
end

"""
InetAddr(ip::IPAddr, port) -> InetAddr

Returns an InetAddr object from ip address `ip` and port number `port`.
fredrikekre marked this conversation as resolved.
Show resolved Hide resolved

# Examples
```jldoctest
julia> Sockets.InetAddr(ip"127.0.0.1", 8000)
Sockets.InetAddr{IPv4}(ip"127.0.0.1", 8000)
```
"""
InetAddr(ip::IPAddr, port) = InetAddr{typeof(ip)}(ip, port)

"""
InetAddr(str::AbstractString, port) -> InetAddr

Returns an InetAddr object from ip address `str` formatted as [`AbstractString`](@ref)
fredrikekre marked this conversation as resolved.
Show resolved Hide resolved
and port number `port`.

!!! compat "Julia 1.2"
constructor from `AbstractString` requires at least Julia 1.2.
fredrikekre marked this conversation as resolved.
Show resolved Hide resolved

# Examples
```jldoctest
julia> Sockets.InetAddr("127.0.0.1", 8000)
Sockets.InetAddr{IPv4}(ip"127.0.0.1", 8000)
```
"""
InetAddr(str::AbstractString, port) = InetAddr(parse(IPAddr, str), port)
function show(io::IO, addr::InetAddr)
show(io, typeof(addr))