Example #1
0
File: ssl.go Project: runcom/gossl
func (self *SSL) Read(b []byte) (int, error) {
	length := len(b)
	ret := C.SSL_read(self.SSL, unsafe.Pointer(&b[0]), C.int(length))
	if err := self.getError(ret); err != nil {
		return 0, err
	}
	// if there's no error, but a return value of 0
	// let's say it's an EOF
	if ret == 0 {
		return 0, io.EOF
	}
	return int(ret), nil
}
Example #2
0
func (c *Conn) read(b []byte) (int, func() error) {
	if len(b) == 0 {
		return 0, nil
	}
	c.mtx.Lock()
	defer c.mtx.Unlock()
	if c.is_shutdown {
		return 0, func() error { return io.EOF }
	}
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	rv, errno := C.SSL_read(c.ssl, unsafe.Pointer(&b[0]), C.int(len(b)))
	if rv > 0 {
		return int(rv), nil
	}
	return 0, c.getErrorHandler(rv, errno)
}
Example #3
0
func (self *SSL) Read(b []byte) (int, error) {
	length := len(b)
	ret := C.SSL_read(self.SSL, unsafe.Pointer(&b[0]), C.int(length))
	return length, self.getError(ret)
}