示例#1
0
文件: ssl.go 项目: 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
}
示例#2
0
文件: conn.go 项目: johnsonz/openssl
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)
}
示例#3
0
文件: ssl.go 项目: partkyle/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))
	return length, self.getError(ret)
}