net: add support for `-d trace_tcp` to ease debugging
parent
40ce18fa3c
commit
17e0a65611
|
@ -34,6 +34,9 @@ pub fn (c TcpConn) close() ? {
|
|||
|
||||
// write_ptr blocks and attempts to write all data
|
||||
pub fn (c TcpConn) write_ptr(b byteptr, len int) ? {
|
||||
$if trace_tcp ? {
|
||||
eprintln('>>> TcpConn.write_ptr | c.sock.handle: $c.sock.handle | b: ${ptr_str(b)} len: $len')
|
||||
}
|
||||
unsafe {
|
||||
mut ptr_base := byteptr(b)
|
||||
mut total_sent := 0
|
||||
|
@ -71,6 +74,9 @@ pub fn (c TcpConn) write_str(s string) ? {
|
|||
|
||||
pub fn (c TcpConn) read_ptr(buf_ptr byteptr, len int) ?int {
|
||||
mut res := wrap_read_result(C.recv(c.sock.handle, buf_ptr, len, 0)) ?
|
||||
$if trace_tcp ? {
|
||||
eprintln('<<< TcpConn.read_ptr | c.sock.handle: $c.sock.handle | buf_ptr: ${ptr_str(buf_ptr)} len: $len | res: $res')
|
||||
}
|
||||
if res > 0 {
|
||||
return res
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue