Showing
1 changed file
with
40 additions
and
10 deletions
| 1 | -/* | ||
| 2 | - * some basic berkley socket stuff....far from beeing complete | ||
| 3 | - */ | ||
| 4 | -#define USE_STRUCT_SCOT_SOCKET | ||
| 5 | - | 1 | +/*************************************************************************** |
| 2 | + * | ||
| 3 | + * socket.c: some basic berkley socket stuff....far from beeing complete | ||
| 4 | + * | ||
| 5 | + * Copyright (C) 2009 Georg Steffers <georg@steffers.org> | ||
| 6 | + * This file is part of gameserver | ||
| 7 | + * | ||
| 8 | + * gameserver is free software: you can redistribute it and/or modify | ||
| 9 | + * it under the terms of the GNU General Public License as published by | ||
| 10 | + * the Free Software Foundation, either version 3 of the License, or | ||
| 11 | + * (at your option) any later version. | ||
| 12 | + * | ||
| 13 | + * This program is distributed in the hope that it will be useful, | ||
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | + * GNU General Public License for more details. | ||
| 17 | + * | ||
| 18 | + * You should have received a copy of the GNU General Public License | ||
| 19 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | + * | ||
| 21 | + * Author: Georg Steffers (gst), georg@steffers.org | ||
| 22 | + * | ||
| 23 | + * Version: 0.0 | ||
| 24 | + * Created: 16.08.2009 19:59:33 | ||
| 25 | + * Revision: none | ||
| 26 | + * | ||
| 27 | + ***************************************************************************/ | ||
| 28 | + | ||
| 29 | +#define USE_STRUCT_SCOT_SOCKET // set for include behaviour | ||
| 30 | + | ||
| 31 | +/* #### HEADER FILE INCLUDES ######################################### */ | ||
| 6 | #include <string.h> | 32 | #include <string.h> |
| 7 | 33 | ||
| 8 | #include <scot/exception.h> | 34 | #include <scot/exception.h> |
| @@ -16,12 +42,16 @@ | @@ -16,12 +42,16 @@ | ||
| 16 | 42 | ||
| 17 | #include <scot_common.h> | 43 | #include <scot_common.h> |
| 18 | 44 | ||
| 45 | +/* #### MACROS - LOCAL TO THIS SOURCE FILE ######################### */ | ||
| 19 | #define SCOT_SOCKET_NEW_FAIL 0 | 46 | #define SCOT_SOCKET_NEW_FAIL 0 |
| 20 | #define SCOT_SOCKET_LISTEN_FAIL 1 | 47 | #define SCOT_SOCKET_LISTEN_FAIL 1 |
| 21 | #define SCOT_SOCKET_ACCEPT_FAIL 2 | 48 | #define SCOT_SOCKET_ACCEPT_FAIL 2 |
| 22 | #define SCOT_SOCKET_CONNECT_FAIL 3 | 49 | #define SCOT_SOCKET_CONNECT_FAIL 3 |
| 23 | #define SCOT_SOCKET_NO_VALID_HOST 4 | 50 | #define SCOT_SOCKET_NO_VALID_HOST 4 |
| 24 | #define SCOT_SOCKET_AF_NOT_IMPLEMENTED 5 | 51 | #define SCOT_SOCKET_AF_NOT_IMPLEMENTED 5 |
| 52 | + | ||
| 53 | + | ||
| 54 | +/* #### VARIABLES - LOCAL TO THIS SOURCE FILE ###################### */ | ||
| 25 | const char * scot_socket_errmsg[] = | 55 | const char * scot_socket_errmsg[] = |
| 26 | { | 56 | { |
| 27 | "[SOCKET]failed to create new socket", | 57 | "[SOCKET]failed to create new socket", |
| @@ -35,13 +65,13 @@ const char * scot_socket_errmsg[] = | @@ -35,13 +65,13 @@ const char * scot_socket_errmsg[] = | ||
| 35 | const char * scot_socket_wrnmsg[] = | 65 | const char * scot_socket_wrnmsg[] = |
| 36 | { | 66 | { |
| 37 | "[SOCKET]there was already an existent socket file.\n" | 67 | "[SOCKET]there was already an existent socket file.\n" |
| 38 | - " i removed that file to let the new instance of the program\n" | ||
| 39 | - " work, but notice that there might be another instance of this\n" | ||
| 40 | - " program running, that is unusable hence now." | 68 | + " i removed that file to let the new instance of the program\n" |
| 69 | + " work, but notice that there might be another instance of this\n" | ||
| 70 | + " program running, that is unusable hence now." | ||
| 41 | }; | 71 | }; |
| 42 | 72 | ||
| 43 | 73 | ||
| 44 | - | 74 | +/* #### FUNCTION DEFINITIONS - EXPORTED FUNCTIONS ################## */ |
| 45 | void | 75 | void |
| 46 | scot_socket_init (uint16_t major, uint16_t minor) | 76 | scot_socket_init (uint16_t major, uint16_t minor) |
| 47 | { | 77 | { |
| @@ -66,7 +96,7 @@ scot_socket_fini (void) | @@ -66,7 +96,7 @@ scot_socket_fini (void) | ||
| 66 | * actualy i found no good reason to bind a socken if one | 96 | * actualy i found no good reason to bind a socken if one |
| 67 | * dont wants to listen to it too. If i find one i will change this. | 97 | * dont wants to listen to it too. If i find one i will change this. |
| 68 | */ | 98 | */ |
| 69 | - void | 99 | +void |
| 70 | scot_socket_listen (const struct scot_socket* s) | 100 | scot_socket_listen (const struct scot_socket* s) |
| 71 | { | 101 | { |
| 72 | excenv_t *ee; | 102 | excenv_t *ee; |
Please
register
or
login
to post a comment