mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
picoev: add more logging of errors (#20558)
This commit is contained in:
parent
0367f343b0
commit
9703029dbe
3 changed files with 69 additions and 26 deletions
|
@ -67,11 +67,9 @@ fn setup_sock(fd int) ! {
|
|||
}
|
||||
|
||||
@[inline]
|
||||
fn req_read(fd int, b &u8, max_len int, idx int) int {
|
||||
fn req_read(fd int, buffer &u8, max_len int, offset int) int {
|
||||
// use `recv` instead of `read` for windows compatibility
|
||||
unsafe {
|
||||
return C.recv(fd, b + idx, max_len - idx, 0)
|
||||
}
|
||||
return unsafe { C.recv(fd, buffer + offset, max_len - offset, 0) }
|
||||
}
|
||||
|
||||
fn fatal_socket_error(fd int) bool {
|
||||
|
@ -102,7 +100,9 @@ fn fatal_socket_error(fd int) bool {
|
|||
fn listen(config Config) !int {
|
||||
// not using the `net` modules sockets, because not all socket options are defined
|
||||
fd := C.socket(config.family, net.SocketType.tcp, 0)
|
||||
assert fd != -1
|
||||
if fd == -1 {
|
||||
return error('Failed to create socket')
|
||||
}
|
||||
|
||||
$if trace_fd ? {
|
||||
eprintln('listen: ${fd}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue