ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/tcp.ext
Revision: 1.3
Committed: Fri Dec 15 19:11:47 2006 UTC (17 years, 4 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
move .ext to server

File Contents

# Content
1 #! perl
2
3 # this listens for new tcp connections and hands them over to the server core
4 # wether this being an extension introduces or reduces stability problems
5 # is unknown as of today.
6
7 use Socket;
8 use IO::Socket::INET;
9
10 our $LISTEN = new IO::Socket::INET
11 LocalPort => cf::settings->csport,
12 Listen => 1,
13 ReuseAddr => 1;
14
15 if (!$LISTEN) {
16 # extension yes, completely stupid, not yet
17 warn "unable to establish listen sockect, exiting.\n";
18 exit (2);
19 }
20
21 Event->io (fd => $LISTEN, poll => 'r', data => cf::WF_AUTOCANCEL, cb => sub {
22 my ($fh, $peername) = $LISTEN->accept
23 or return;
24
25 my $fd = fileno $fh;
26 my $host = inet_ntoa +(sockaddr_in $peername)[1];
27
28 warn "new connection from $host\n";
29
30 cf::add_client_socket $fd, $host;
31 });