func (p *TUnixDomain) Write(buf []byte) (int, error) {
	if !p.IsOpen() {
		return 0, thrift.NewTTransportException(thrift.NOT_OPEN, "Connection not open")
	}
	p.pushDeadline(false, true)
	return p.conn.Write(buf)
}
func (p *TUnixDomain) Read(buf []byte) (int, error) {
	if !p.IsOpen() {
		return 0, thrift.NewTTransportException(thrift.NOT_OPEN, "Connection not open")
	}
	p.pushDeadline(true, false)
	n, err := p.conn.Read(buf)
	return n, thrift.NewTTransportExceptionFromError(err)
}
// Connects the socket, creating a new socket object if necessary.
func (p *TUnixDomain) Open() error {
	if p.IsOpen() {
		return thrift.NewTTransportException(thrift.ALREADY_OPEN, "Socket already connected.")
	}
	if p.addr == nil {
		return thrift.NewTTransportException(thrift.NOT_OPEN, "Cannot open nil address.")
	}
	if len(p.addr.Network()) == 0 {
		return thrift.NewTTransportException(thrift.NOT_OPEN, "Cannot open bad network name.")
	}
	if len(p.addr.String()) == 0 {
		return thrift.NewTTransportException(thrift.NOT_OPEN, "Cannot open bad address.")
	}
	var err error
	if p.conn, err = net.DialTimeout(p.addr.Network(), p.addr.String(), p.timeout); err != nil {
		return thrift.NewTTransportException(thrift.NOT_OPEN, err.Error())
	}
	return nil
}
// Connects the socket, creating a new socket object if necessary.
func (p *TServerUnixDomain) Open() error {
	if p.IsListening() {
		return thrift.NewTTransportException(thrift.ALREADY_OPEN, "Server socket already open")
	}
	if l, err := net.Listen(p.addr.Network(), p.addr.String()); err != nil {
		return err
	} else {
		p.listener = l
	}
	return nil
}
func (p *TServerUnixDomain) Accept() (thrift.TTransport, error) {
	p.mu.RLock()
	interrupted := p.interrupted
	p.mu.RUnlock()

	if interrupted {
		return nil, errors.New("Transport Interrupted")
	}
	if p.listener == nil {
		return nil, thrift.NewTTransportException(thrift.NOT_OPEN, "No underlying server socket")
	}
	conn, err := p.listener.Accept()
	if err != nil {
		return nil, thrift.NewTTransportExceptionFromError(err)
	}
	return thrift.NewTSocketFromConnTimeout(conn, p.clientTimeout), nil
}