v/vlib/net/websocket/io.v

24 lines
549 B
V
Raw Normal View History

module websocket
2020-05-17 13:51:18 +02:00
fn (mut ws Client) write_to_server(buf voidptr, len int) int {
mut bytes_written := 0
ws.write_lock.m_lock()
if ws.is_ssl {
bytes_written = C.SSL_write(ws.ssl, buf, len)
} else {
bytes_written = C.write(ws.socket.sockfd, buf, len)
}
ws.write_lock.unlock()
return bytes_written
}
fn (ws &Client) read_from_server(buffer byteptr, buffer_size int) int {
mut res := 0
if ws.is_ssl {
res = C.SSL_read(ws.ssl, buffer, buffer_size)
} else {
res = C.read(ws.socket.sockfd, buffer, buffer_size)
}
return res
2020-05-26 12:50:37 +02:00
}