func (conn *DeviceConnection) Reader() io.Reader {
	return conn.c
}
Reader exposes the underlying net.Conn as io.Reader
package ios
import (
	"crypto/tls"
	"encoding/binary"
	"io"
	"net"
	"time"
	log "github.com/sirupsen/logrus"
)
type DeviceConnectionInterface interface {
	Close()
	Send(message []byte) error
	Reader() io.Reader
	Writer() io.Writer
	EnableSessionSsl(pairRecord PairRecord) error
	EnableSessionSslServerMode(pairRecord PairRecord)
	EnableSessionSslHandshakeOnly(pairRecord PairRecord) error
	EnableSessionSslServerModeHandshakeOnly(pairRecord PairRecord)
	DisableSessionSSL()
	Conn() net.Conn
}
type DeviceConnection struct {
	c               net.Conn
	unencryptedConn net.Conn
}
func NewDeviceConnection(socketToConnectTo string) (*DeviceConnection, error) {
	conn := &DeviceConnection{}
	return conn, conn.connectToSocketAddress(socketToConnectTo)
}
func NewDeviceConnectionWithConn(conn net.Conn) *DeviceConnection {
	return &DeviceConnection{c: conn}
}
func (conn *DeviceConnection) connectToSocketAddress(socketAddress string) error {
	c, err := net.Dial("unix", socketAddress)
	if err != nil {
		return err
	}
	log.Debug("Opening connection:", &c)
	conn.c = c
	return nil
}
func (conn *DeviceConnection) Close() {
	log.Debug("Closing connection:", &conn.c)
	conn.c.Close()
}
func (conn *DeviceConnection) Send(bytes []byte) error {
	n, err := conn.c.Write(bytes)
	if n < len(bytes) {
		log.Errorf("DeviceConnection failed writing %d bytes, only %d sent", len(bytes), n)
	}
	if err != nil {
		log.Errorf("Failed sending: %s", err)
		conn.Close()
		return err
	}
	return nil
}