Ejemplo n.º 1
0
func (this *TUnixSocket) Open() error {
	if this.IsListening() {
		return thrift.NewTTransportException(thrift.ALREADY_OPEN,
			"Server socket already open")
	}
	if l, err := net.Listen(this.addr.Network(), this.addr.String()); err != nil {
		return err
	} else {
		this.listener = l
	}
	return nil
}
Ejemplo n.º 2
0
func (this *TUnixSocket) Accept() (thrift.TTransport, error) {
	if this.interrupted {
		return nil, errors.New("Transport Interrupted")
	}
	if this.listener == nil {
		return nil, thrift.NewTTransportException(thrift.NOT_OPEN,
			"No underlying server socket")
	}
	conn, err := this.listener.Accept()
	if err != nil {
		return nil, thrift.NewTTransportExceptionFromError(err)
	}
	return thrift.NewTSocketFromConnTimeout(conn, this.clientTimeout), nil
}