]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/perl/lib/Thrift/ServerSocket.pm
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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
27 use Thrift
::Transport
;
30 package Thrift
::ServerSocket
;
31 use base
qw( Thrift::ServerTransport );
32 use version
0.77; our $VERSION = version-
>declare("$Thrift::VERSION");
36 # Legacy construction takes one argument, port number.
37 # New construction takes a hash:
38 # @param[in] host host interface to listen on (undef = all interfaces)
39 # @param[in] port port number to listen on (required)
40 # @param[in] queue the listen queue size (default if not specified is 128)
41 # @example my $serversock = Thrift::ServerSocket->new(host => undef, port => port)
45 my $classname = shift;
49 # Support both old-style "port number" construction and newer...
50 if (ref($args) eq 'HASH') {
54 $self = { port
=> $args };
57 if (not defined $self->{queue
}) {
61 return bless($self, $classname);
68 my $sock = $self->__listen() || do {
69 my $error = ref($self) . ': Could not bind to ' . '*:' . $self->{port
} . ' (' . $! . ')';
72 $self->{debugHandler
}->($error);
75 die Thrift
::TTransportException-
>new($error, Thrift
::TTransportException
::NOT_OPEN
);
78 $self->{handle
} = $sock;
85 if ( exists $self->{handle
} and defined $self->{handle
} ) {
86 my $client = $self->{handle
}->accept();
87 my $result = $self->__client();
88 $result->{handle
} = IO
::Select-
>new($client);
99 if ( exists $self->{handle
} and defined $self->{handle
} )
101 $self->{handle
}->close();
106 ### Overridable methods
111 return Thrift
::Socket-
>new();
117 return IO
::Socket
::INET-
>new(LocalAddr
=> $self->{host
},
118 LocalPort
=> $self->{port
},
120 Listen
=> $self->{queue
},