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

38 lines
508 B
V
Raw Normal View History

module net
#flag -lws2_32
#include <winsock2.h>
#include <Ws2tcpip.h>
struct C.WSAData {
mut:
wVersion u16
2020-05-16 17:12:23 +03:00
wHighVersion u16
szDescription [257]byte
szSystemStatus [129]byte
iMaxSockets u16
iMaxUdpDg u16
lpVendorInfo byteptr
}
const (
2020-05-22 18:36:09 +03:00
wsa_v22 = 0x202 // C.MAKEWORD(2, 2)
)
fn init() {
mut wsadata := C.WSAData{}
2020-05-22 18:36:09 +03:00
res := C.WSAStartup(wsa_v22, &wsadata)
if res != 0 {
panic('socket: WSAStartup failed')
}
}
2019-10-10 20:24:36 +03:00
fn error_code() int {
return C.WSAGetLastError()
}
pub const (
2020-05-22 18:36:09 +03:00
msg_nosignal = 0
)