]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/perl/lib/Thrift/UnixSocket.pm
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / perl / lib / Thrift / UnixSocket.pm
CommitLineData
f67539c2
TL
1#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20use 5.10.0;
21use strict;
22use warnings;
23
24use Thrift;
25use Thrift::Socket;
26
27use IO::Socket::UNIX;
28
29package Thrift::UnixSocket;
30use base qw( Thrift::Socket );
31use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
32
33#
34# Constructor.
35# Takes a unix domain socket filename.
36# See Thrift::Socket for base class parameters.
37# @param[in] path path to unix socket file
38# @example my $sock = Thrift::UnixSocket->new($path);
39#
40sub new
41{
42 my $classname = shift;
43 my $self = $classname->SUPER::new();
44 $self->{path} = shift;
45 return bless($self, $classname);
46}
47
48sub __open
49{
50 my $self = shift;
51
52 my $sock = IO::Socket::UNIX->new(
53 Type => IO::Socket::SOCK_STREAM,
54 Peer => $self->{path})
55 || do {
56 my $error = 'UnixSocket: Could not connect to ' .
57 $self->{path} . ' (' . $! . ')';
58 if ($self->{debug}) {
59 $self->{debugHandler}->($error);
60 }
61 die Thrift::TTransportException->new($error, Thrift::TTransportException::NOT_OPEN);
62 };
63
64 return $sock;
65}
66
671;