/*
Copyright (c) [2023] [squallzhao]
fountain is licensed under APACHE LICENSE, VERSION 2.0.
You can use this software according to the terms and conditions of the APACHE LICENSE, VERSION 2.0.
You may obtain a copy of APACHE LICENSE, VERSION 2.0 at: https://www.apache.org/licenses/LICENSE-2.0
*/
package microservice.web.socket
import std.io.*
import std.socket.*
public class Acceptor{
var server: TcpServerSocket;
public init(port: UInt16){
this.server = TcpServerSocket(bindAt: port);
this.server.bind();
}
public func accept(): TcpSocket{
let socket = server.accept();
return socket
}
public func stop():Unit{
server.close();
}
}