ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/tcp.ext
Revision: 1.20
Committed: Fri Feb 3 03:01:45 2012 UTC (12 years, 3 months ago) by root
Branch: MAIN
Changes since 1.19: +3 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.17 #! perl # mandatory
2 root 1.1
3     # this listens for new tcp connections and hands them over to the server core
4 root 1.19 # whether this being an extension introduces or reduces stability problems
5 root 1.1 # is unknown as of today.
6    
7     use Socket;
8 root 1.12 use AnyEvent::Socket;
9 root 1.1
10 root 1.20 CONF BIND_ADDRESSES = [[undef, 13327]];
11    
12 root 1.15 our @LISTENERS;
13 root 1.12
14 root 1.20 for (@$BIND_ADDRESSES) {
15 root 1.12 my ($host, $port) = @$_;
16 root 1.16 cf::info "listening on ", (format_hostport $host, $port), "\n";
17 root 1.12
18 root 1.15 push @LISTENERS, tcp_server $host, $port, sub {
19 root 1.12 my ($fh, $host, $port) = @_
20     or return;
21    
22 root 1.18 my $lhost = AnyEvent::Socket::format_address
23     +(AnyEvent::Socket::unpack_sockaddr getsockname $fh)[1];
24    
25     cf::info "new connection from ", (format_hostport $host, $port), "\n"
26     if $lhost ne $host; # do not log connections from the host, e.g. for watchdogs
27 root 1.12
28 root 1.13 cf::client::create fileno $fh, $host;
29 root 1.12 };
30 root 1.1 }
31