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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user