~ubuntu-branches/ubuntu/wily/steam/wily

« back to all changes in this revision

Viewing changes to server/net/port/coal.pike

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-10-29 19:51:18 UTC
  • mfrom: (1.1.4) (0.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029195118-b9bxciz5hwx5z459
Tags: 1:1.0.0.39-2ubuntu1
Add an epoch to the version number as there was an unrelated steam package
in the archive with a higher version number.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2004  Thomas Bopp, Thorsten Hampel, Ludger Merkens
2
 
 *
3
 
 *  This program is free software; you can redistribute it and/or modify
4
 
 *  it under the terms of the GNU General Public License as published by
5
 
 *  the Free Software Foundation; either version 2 of the License, or
6
 
 *  (at your option) any later version.
7
 
 *
8
 
 *  This program is distributed in the hope that it will be useful,
9
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 *  GNU General Public License for more details.
12
 
 *
13
 
 *  You should have received a copy of the GNU General Public License
14
 
 *  along with this program; if not, write to the Free Software
15
 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
 
 * 
17
 
 * $Id: coal.pike,v 1.1.1.1 2006/03/27 12:40:18 exodusd Exp $
18
 
 */
19
 
 
20
 
constant cvs_version="$Id: coal.pike,v 1.1.1.1 2006/03/27 12:40:18 exodusd Exp $";
21
 
 
22
 
inherit Stdio.Port;
23
 
 
24
 
#include <config.h>
25
 
#include <macros.h>
26
 
 
27
 
/***
28
 
 * Setup a new connection with a socket.
29
 
 *
30
 
 * @author Thomas Bopp 
31
 
 */
32
 
 
33
 
void setup_port() 
34
 
{
35
 
    object          tmp, u;
36
 
 
37
 
    tmp = ::accept();
38
 
    if ( !objectp(tmp) ) {
39
 
        werror("Failed to bind socket !\n");
40
 
        return;
41
 
    }
42
 
    master()->register_user((u=new(OBJ_COAL, tmp)));
43
 
}
44
 
 
45
 
/**
46
 
 * Gets the program for the corresponding socket.
47
 
 *  
48
 
 * @return The socket for this port.
49
 
 * @author <a href="mailto:astra@upb.de">Thomas Bopp</a>) 
50
 
 */
51
 
program get_socket_program()
52
 
{
53
 
    return (program)OBJ_COAL;
54
 
}
55
 
 
56
 
/**
57
 
 * Called to open the port and binds the configured coal port.
58
 
 *  
59
 
 * @return true or false
60
 
 * @author <a href="mailto:astra@upb.de">Thomas Bopp</a>) 
61
 
 */
62
 
bool open_port()
63
 
{
64
 
    string ip = _Server->query_config("ip");
65
 
    if ( ! stringp(ip) || sizeof(ip)==0 ) ip = 0;
66
 
    if ( !bind(_Server->query_config("port"), setup_port, ip) ) {
67
 
        werror("Failed to open coal socket on "
68
 
            + (stringp(ip) ? ip+":" : "port ")
69
 
            + _Server->query_config("port") + " !\n");
70
 
        return false;
71
 
    }
72
 
    MESSAGE("COAL port opened on " + (stringp(ip) ? ip+":" : "port ")
73
 
        + _Server->query_config("port"));
74
 
    return true;
75
 
}
76
 
 
77
 
bool close_port()
78
 
{
79
 
}
80
 
 
81
 
string get_port_config()
82
 
{
83
 
    return "port";
84
 
}
85
 
 
86
 
string get_port_name()
87
 
{
88
 
    return "coal";
89
 
}
90
 
 
91
 
bool port_required() { return false; }
92
 
int get_port() { return _Server->query_config("port"); }
93
 
string describe() { return "COAL(#"+get_port()+")"; }    
94
 
 
95
 
 
96
 
 
97
 
 
98
 
 
99
 
 
100
 
 
101
 
 
102