From 8230b2a054dba5fa35b9761ecb3b8a30cd27eb52 Mon Sep 17 00:00:00 2001 From: rofinn Date: Tue, 15 May 2018 12:54:03 -0500 Subject: [PATCH] Add Sockets module. --- Project.toml | 3 ++- README.md | 4 ++++ src/Compat.jl | 17 +++++++++++++++++ test/runtests.jl | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 40ba72e9b..378f1ac5b 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/README.md b/README.md index fdd7604fd..6c0751817 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/src/Compat.jl b/src/Compat.jl index a36734429..519e6c408 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index a85f790c7..f17b894d5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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