diff --git a/Sources/NIO/Bootstrap.swift b/Sources/NIO/Bootstrap.swift index 864846c08..66c492c0d 100644 --- a/Sources/NIO/Bootstrap.swift +++ b/Sources/NIO/Bootstrap.swift @@ -89,7 +89,7 @@ public final class ServerBootstrap { /// - parameters: /// - host: The host to bind on. /// - port: The port to bind on. - public func bind(to host: String, on port: Int32) -> EventLoopFuture { + public func bind(to host: String, on port: Int) -> EventLoopFuture { let evGroup = group do { let address = try SocketAddress.newAddressResolving(host: host, port: port) diff --git a/Sources/NIO/GetaddrinfoResolver.swift b/Sources/NIO/GetaddrinfoResolver.swift index f31cc2836..66c12290b 100644 --- a/Sources/NIO/GetaddrinfoResolver.swift +++ b/Sources/NIO/GetaddrinfoResolver.swift @@ -80,7 +80,7 @@ internal class GetaddrinfoResolver: Resolver { var info: UnsafeMutablePointer? guard getaddrinfo(host, String(port), nil, &info) == 0 else { - self.fail(error: SocketAddressError.unknown(host: host, port: Int32(port))) + self.fail(error: SocketAddressError.unknown(host: host, port: port)) return } diff --git a/Sources/NIO/ServerSocket.swift b/Sources/NIO/ServerSocket.swift index 474d0e0c0..9f48444e7 100644 --- a/Sources/NIO/ServerSocket.swift +++ b/Sources/NIO/ServerSocket.swift @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// final class ServerSocket: BaseSocket { - public class func bootstrap(protocolFamily: Int32, host: String, port: Int32) throws -> ServerSocket { + public class func bootstrap(protocolFamily: Int32, host: String, port: Int) throws -> ServerSocket { let socket = try ServerSocket(protocolFamily: protocolFamily) try socket.bind(to: SocketAddress.newAddressResolving(host: host, port: port)) try socket.listen() diff --git a/Sources/NIO/SocketAddresses.swift b/Sources/NIO/SocketAddresses.swift index 286f0dc76..e4c7028c1 100644 --- a/Sources/NIO/SocketAddresses.swift +++ b/Sources/NIO/SocketAddresses.swift @@ -15,7 +15,7 @@ /// Special `Error` that may be thrown if we fail to create a `SocketAddress`. public enum SocketAddressError: Error { /// The host is unknown (could not be resolved). - case unknown(host: String, port: Int32) + case unknown(host: String, port: Int) /// The requested `SocketAddress` is not supported. case unsupported /// The requested UDS path is too long. @@ -230,7 +230,7 @@ public enum SocketAddress: CustomStringConvertible { /// - port: the port itself /// - returns: the `SocketAddress` for the host / port pair. /// - throws: a `SocketAddressError.unknown` if we could not resolve the `host`, or `SocketAddressError.unsupported` if the address itself is not supported (yet). - public static func newAddressResolving(host: String, port: Int32) throws -> SocketAddress { + public static func newAddressResolving(host: String, port: Int) throws -> SocketAddress { var info: UnsafeMutablePointer? /* FIXME: this is blocking! */ diff --git a/Sources/NIOEchoServer/main.swift b/Sources/NIOEchoServer/main.swift index 4a89cc820..d0eabc158 100644 --- a/Sources/NIOEchoServer/main.swift +++ b/Sources/NIOEchoServer/main.swift @@ -69,15 +69,15 @@ let arg1 = arguments.dropFirst().first let arg2 = arguments.dropFirst().dropFirst().first let defaultHost = "::1" -let defaultPort: Int32 = 9999 +let defaultPort = 9999 enum BindTo { - case ip(host: String, port: Int32) + case ip(host: String, port: Int) case unixDomainSocket(path: String) } let bindTarget: BindTo -switch (arg1, arg1.flatMap { Int32($0) }, arg2.flatMap { Int32($0) }) { +switch (arg1, arg1.flatMap { Int($0) }, arg2.flatMap { Int($0) }) { case (.some(let h), _ , .some(let p)): /* we got two arguments, let's interpret that as host and port */ bindTarget = .ip(host: h, port: p) diff --git a/Sources/NIOHTTP1Server/main.swift b/Sources/NIOHTTP1Server/main.swift index a3ac92338..6f6a34796 100644 --- a/Sources/NIOHTTP1Server/main.swift +++ b/Sources/NIOHTTP1Server/main.swift @@ -357,17 +357,17 @@ let arg2 = arguments.dropFirst().dropFirst().first let arg3 = arguments.dropFirst().dropFirst().dropFirst().first let defaultHost = "::1" -let defaultPort: Int32 = 8888 +let defaultPort = 8888 let defaultHtdocs = "/dev/null/" enum BindTo { - case ip(host: String, port: Int32) + case ip(host: String, port: Int) case unixDomainSocket(path: String) } let htdocs: String let bindTarget: BindTo -switch (arg1, arg1.flatMap { Int32($0) }, arg2, arg2.flatMap { Int32($0) }, arg3) { +switch (arg1, arg1.flatMap { Int($0) }, arg2, arg2.flatMap { Int($0) }, arg3) { case (.some(let h), _ , _, .some(let p), let maybeHtdocs): /* second arg an integer --> host port [htdocs] */ bindTarget = .ip(host: h, port: p)