//export go_conn_bio_write func go_conn_bio_write(bio *C.BIO, buf *C.char, num C.int) C.int { conn := (*Conn)(bio.ptr) data := goSliceFromCString(buf, int(num)) n, err := conn.conn.Write(data) if err != nil && err != io.EOF { //We expect either a syscall error //or a netOp error wrapping a syscall error TESTERR: switch err.(type) { case syscall.Errno: C.set_errno(C.int(err.(syscall.Errno))) case *net.OpError: err = err.(*net.OpError).Err break TESTERR } return C.int(-1) } return C.int(n) }
//export go_conn_bio_read func go_conn_bio_read(bio *C.BIO, buf *C.char, num C.int) C.int { var conn *Conn = (*Conn)(bio.ptr) var size int = int(num) data := GoSliceFromCString(buf, size) n, err := conn.conn.Read(data) if err != nil && err != io.EOF { //We expect either a syscall error //or a netOp error wrapping a syscall error TESTERR: switch err.(type) { case syscall.Errno: C.set_errno(C.int(err.(syscall.Errno))) case *net.OpError: err = err.(*net.OpError).Err break TESTERR } return C.int(-1) } else if err == io.ErrUnexpectedEOF { return 0 } return C.int(n) }