Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SwifterExample/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ server["/files/:path"] = directoryBrowser("/")

let semaphore = DispatchSemaphore(value: 0)
do {
try server.start(9080, forceIPv4: true)
try server.start(9080, forceIPv4: true){_ in}
print("Server has started ( port = \(try server.port()) ). Try to connect now...")
semaphore.wait()
} catch {
Expand Down
3 changes: 2 additions & 1 deletion Xcode/Sources/HttpServerIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ open class HttpServerIO {
}

@available(macOS 10.10, *)
public func start(_ port: in_port_t = 8080, forceIPv4: Bool = false, priority: DispatchQoS.QoSClass = DispatchQoS.QoSClass.background) throws {
public func start(_ port: in_port_t = 8080, forceIPv4: Bool = false, priority: DispatchQoS.QoSClass = DispatchQoS.QoSClass.background, completion: (Bool) -> ()) throws {
guard !self.operating else { return }
stop()
self.state = .starting
let address = forceIPv4 ? listenAddressIPv4 : listenAddressIPv6
self.socket = try Socket.tcpSocketForListen(port, forceIPv4, SOMAXCONN, address)
self.state = .running
completion(true)
DispatchQueue.global(qos: priority).async { [weak self] in
guard let strongSelf = self else { return }
guard strongSelf.operating else { return }
Expand Down
Loading