mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
x.websockets: new websockets module on top of x.net (#6189)
This commit is contained in:
@@ -92,4 +92,4 @@ fn C.FD_SET()
|
||||
fn C.FD_ISSET() bool
|
||||
|
||||
[typedef]
|
||||
struct C.fd_set {}
|
||||
pub struct C.fd_set {}
|
||||
|
||||
@@ -70,6 +70,25 @@ pub fn (c TcpConn) write_string(s string) ? {
|
||||
return c.write_ptr(s.str, s.len)
|
||||
}
|
||||
|
||||
pub fn (c TcpConn) read_into_ptr(buf_ptr byteptr, len int) ?int {
|
||||
res := C.recv(c.sock.handle, buf_ptr, len, 0)
|
||||
|
||||
if res >= 0 {
|
||||
return res
|
||||
}
|
||||
|
||||
code := error_code()
|
||||
match code {
|
||||
error_ewouldblock {
|
||||
c.wait_for_read()?
|
||||
return socket_error(C.recv(c.sock.handle, buf_ptr, len, 0))
|
||||
}
|
||||
else {
|
||||
wrap_error(code)?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (c TcpConn) read_into(mut buf []byte) ?int {
|
||||
res := C.recv(c.sock.handle, buf.data, buf.len, 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user