Skip to content

Commit

Permalink
Some doctests for Sockets (#27301)
Browse files Browse the repository at this point in the history
* Some doctests for Sockets

* Use julia-repl instead of jldoctest
  • Loading branch information
kshyatt authored and fredrikekre committed May 30, 2018
1 parent 6c43314 commit 45836fe
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions stdlib/Sockets/src/addrinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ end
getalladdrinfo(host::AbstractString) -> Vector{IPAddr}
Gets all of the IP addresses of the `host`.
Uses the operating system's underlying getaddrinfo implementation, which may do a DNS lookup.
Uses the operating system's underlying `getaddrinfo` implementation, which may do a DNS lookup.
# Example
```julia-repl
julia> getalladdrinfo("google.com")
2-element Array{IPAddr,1}:
ip"172.217.6.174"
ip"2607:f8b0:4000:804::200e"
```
"""
function getalladdrinfo(host::String)
isascii(host) || error("non-ASCII hostname: $host")
Expand Down Expand Up @@ -137,7 +145,13 @@ end
getnameinfo(host::IPAddr) -> String
Performs a reverse-lookup for IP address to return a hostname and service
using the operating system's underlying getnameinfo implementation.
using the operating system's underlying `getnameinfo` implementation.
# Examples
```julia-repl
julia> getnameinfo(Sockets.IPv4("8.8.8.8"))
"google-public-dns-a.google.com"
```
"""
function getnameinfo(address::Union{IPv4, IPv6})
req = Libc.malloc(Base._sizeof_uv_getnameinfo)
Expand Down Expand Up @@ -203,6 +217,12 @@ const _sizeof_uv_interface_address = ccall(:jl_uv_sizeof_interface_address,Int32
getipaddr() -> IPAddr
Get the IP address of the local machine.
# Examples
```julia-repl
julia> getipaddr()
ip"192.168.1.28"
```
"""
function getipaddr()
addr_ref = Ref{Ptr{UInt8}}(C_NULL)
Expand Down

0 comments on commit 45836fe

Please sign in to comment.