1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net: ipv6 support, merge unix+ip;[pack:x] attribute (#9904)

This commit is contained in:
Emily Hudson
2021-06-13 21:53:38 +01:00
committed by GitHub
parent fa9fa77a5f
commit 535dcac8fa
52 changed files with 1277 additions and 524 deletions

View File

@@ -15,6 +15,7 @@ mut:
message_callbacks []MessageEventHandler // new message callback functions
close_callbacks []CloseEventHandler // close message callback functions
pub:
family net.AddrFamily = .ip
port int // port used as listen to incoming connections
is_ssl bool // true if secure connection (not supported yet on server)
pub mut:
@@ -34,9 +35,10 @@ pub mut:
}
// new_server instance a new websocket server on provided port and route
pub fn new_server(port int, route string) &Server {
pub fn new_server(family net.AddrFamily, port int, route string) &Server {
return &Server{
ls: 0
family: family
port: port
logger: &log.Log{
level: .info
@@ -53,7 +55,7 @@ pub fn (mut s Server) set_ping_interval(seconds int) {
// listen start listen and process to incoming connections from websocket clients
pub fn (mut s Server) listen() ? {
s.logger.info('websocket server: start listen on port $s.port')
s.ls = net.listen_tcp(s.port) ?
s.ls = net.listen_tcp(s.family, ':$s.port') ?
s.set_state(.open)
go s.handle_ping()
for {