Skip to content

Commit

Permalink
Add Sockets module.
Browse files Browse the repository at this point in the history
  • Loading branch information
rofinn committed May 15, 2018
1 parent 09337ca commit 8230b2a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
IterativeEigensolvers = "de555fa4-b82f-55e7-8b71-53f60bbc027d"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Expand All @@ -20,6 +20,7 @@ REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
SharedArrays = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ Currently, the `@compat` macro supports the following syntaxes:
* `using Compat.Markdown` is provided on versions older than 0.7, where this library is
not yet part of the standard library ([#25738]).

* `using Compat.Sockets` is provided on versions older than 0.7, where this library is
not yet part of the standard library ([#25935])

## New functions, macros, and methods

* `@views` takes an expression and converts all slices to views ([#20164]), while
Expand Down Expand Up @@ -610,6 +613,7 @@ includes this fix. Find the minimum version from there.
[#25819]: https://github.com/JuliaLang/julia/issues/25819
[#25873]: https://github.com/JuliaLang/julia/issues/25873
[#25896]: https://github.com/JuliaLang/julia/issues/25896
[#25935]: https://github.com/JuliaLang/julia/issues/25935
[#25959]: https://github.com/JuliaLang/julia/issues/25959
[#25989]: https://github.com/JuliaLang/julia/issues/25989
[#25990]: https://github.com/JuliaLang/julia/issues/25990
Expand Down
17 changes: 17 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ __precompile__()

module Compat

# https://github.com/JuliaLang/julia/pull/25935
if VERSION < v"0.7.0-DEV.4442"
@eval module Sockets
import Base:
@ip_str, IPAddr, IPv4, IPv6, UDPSocket, TCPSocket,
accept, connect, getaddrinfo, getipaddr, getsockname, listen,
listenany, recv, recvfrom, send

export
@ip_str, IPAddr, IPv4, IPv6, UDPSocket, TCPSocket,
accept, connect, getaddrinfo, getipaddr, getsockname, listen,
listenany, recv, recvfrom, send
end
else
import Sockets
end

include("compatmacro.jl")

@static if !isdefined(Base, :devnull) #25959
Expand Down
14 changes: 14 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,20 @@ import Compat.Markdown
@test stderr === STDERR
end

# 0.7.0-DEV.3666
module TestSockets
using Compat
using Compat.Sockets
using Compat.Test

@test isdefined(@__MODULE__, :UDPSocket)
@test isdefined(@__MODULE__, :connect)
@test isdefined(@__MODULE__, :listen)
@test isdefined(@__MODULE__, :recv)

@test ip"127.0.0.1".host == UInt32(2130706433)
end

# 0.7.0-DEV.3526
module TestNames
export foo
Expand Down

0 comments on commit 8230b2a

Please sign in to comment.