Revision 25
moved more code around
trunk/code/projects/colonet/ColonetServer/includes/ColonetServer.h | ||
---|---|---|
14 | 14 |
ColonetServer(); |
15 | 15 |
~ColonetServer(); |
16 | 16 |
int initialize_server(int argc, char * argv[]); |
17 |
|
|
17 |
|
|
18 |
int start_listening(); |
|
19 |
|
|
18 | 20 |
int log_error(char * error_message); |
19 | 21 |
int log_message(char * message); |
20 | 22 |
|
... | ... | |
22 | 24 |
|
23 | 25 |
ConnectionPool * get_connection_pool_pointer(); |
24 | 26 |
|
25 |
int get_listen_socket(); |
|
26 |
|
|
27 | 27 |
private: |
28 | 28 |
ConnectionPool connection_pool; |
29 | 29 |
Log logger; |
trunk/code/projects/colonet/ColonetServer/ColonetServer.cpp | ||
---|---|---|
53 | 53 |
return 0; |
54 | 54 |
} |
55 | 55 |
|
56 |
int ColonetServer::start_listening() { |
|
57 |
if (listen(listen_socket, LISTEN_BACKLOG) < 0) { |
|
58 |
log_error("\t\nThere was an error telling the socket to " |
|
59 |
"listen for connections from clients. Terminating Server...\n"); |
|
60 |
return -1; |
|
61 |
} |
|
62 |
return 0; |
|
63 |
} |
|
56 | 64 |
|
57 | 65 |
int ColonetServer::log_error(char * error_message) { |
58 | 66 |
return logger.logMessage(LOG_TYPE_ERROR, error_message); |
... | ... | |
135 | 143 |
return &connection_pool; |
136 | 144 |
} |
137 | 145 |
|
138 |
int ColonetServer::get_listen_socket() { |
|
139 |
return listen_socket; |
|
140 |
} |
|
141 |
|
|
142 | 146 |
int ColonetServer::initialize_wireless() |
143 | 147 |
{ |
144 | 148 |
char* log_filename = NULL; |
... | ... | |
214 | 218 |
return -1; |
215 | 219 |
} |
216 | 220 |
|
217 |
if (listen(colonet_server.get_listen_socket(), LISTEN_BACKLOG) < 0) { |
|
218 |
colonet_server.log_error("\t\nThere was an error telling the socket to " |
|
219 |
"listen for connections from clients. Terminating Server...\n"); |
|
221 |
if (colonet_server.start_listening() < 0) { |
|
220 | 222 |
return -1; |
221 | 223 |
} |
222 |
|
|
224 |
|
|
223 | 225 |
colonet_server.run_server(); |
224 | 226 |
|
225 | 227 |
return 0; |
Also available in: Unified diff