GeezerVison is showing github.com — Fix port configuration being ignored (#42) · code-goblin/http@fee5702
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Sources/HTTP/HTTPServer.swift +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,7 +34,7 @@ public class HTTPServer: HTTPServing { | 34 | 34 |
| 35 | 35 | /// Start the HTTP server on the given `port`, using `handler` to process incoming requests | 36 | 36 | public func start(port: Int = 0, handler: @escaping HTTPRequestHandler) throws { | 37 | | - try server.start(handler: handler) | | 37 | + try server.start(port: port, handler: handler) | 38 | 38 | } | 39 | 39 |
| 40 | 40 | /// Stop the server | |
Collapse file Copy file name to clipboardExpand all lines: Sources/HTTP/PoCSocket/PoCSocket.swift +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -201,14 +201,14 @@ internal class PoCSocket { | 201 | 201 | #if os(Linux) | 202 | 202 | var addr = sockaddr_in( | 203 | 203 | sin_family: sa_family_t(AF_INET), | 204 | | - sin_port: UInt16(port), | | 204 | + sin_port: htons(UInt16(port)), | 205 | 205 | sin_addr: in_addr(s_addr: in_addr_t(0)), | 206 | 206 | sin_zero:(0, 0, 0, 0, 0, 0, 0, 0)) | 207 | 207 | #else | 208 | 208 | var addr = sockaddr_in( | 209 | 209 | sin_len: UInt8(MemoryLayout<sockaddr_in>.stride), | 210 | 210 | sin_family: UInt8(AF_INET), | 211 | | - sin_port: UInt16(port), | | 211 | + sin_port: (Int(OSHostByteOrder()) != OSLittleEndian ? UInt16(port) : _OSSwapInt16(UInt16(port))), | 212 | 212 | sin_addr: in_addr(s_addr: in_addr_t(0)), | 213 | 213 | sin_zero:(0, 0, 0, 0, 0, 0, 0, 0)) | 214 | 214 | #endif | |
|