diff options
author | Astonex <softukitu@gmail.com> | 2013-07-24 00:32:50 +0100 |
---|---|---|
committer | Astonex <softukitu@gmail.com> | 2013-07-24 00:32:50 +0100 |
commit | 29aa702a4f0cc50c091e0e9624d5ee897138ddf3 (patch) | |
tree | d94b6894a004509b3cbc756a3b0a4fb1eb0e4791 /core/network.c | |
parent | b7a4c20279ba32e89119c78c2e78ee279358d338 (diff) |
Added simple init_networking() error checking
Diffstat (limited to 'core/network.c')
-rw-r--r-- | core/network.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/network.c b/core/network.c index 6337651a..fa6c99fc 100644 --- a/core/network.c +++ b/core/network.c | |||
@@ -101,8 +101,8 @@ int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length) | |||
101 | bind to ip and port | 101 | bind to ip and port |
102 | ip must be in network order EX: 127.0.0.1 = (7F000001) | 102 | ip must be in network order EX: 127.0.0.1 = (7F000001) |
103 | port is in host byte order (this means don't worry about it) | 103 | port is in host byte order (this means don't worry about it) |
104 | returns 0 if no problems | 104 | returns 0 if no problems |
105 | TODO: add something to check if there are errors */ | 105 | returns -1 if there are problems */ |
106 | int init_networking(IP ip ,uint16_t port) | 106 | int init_networking(IP ip ,uint16_t port) |
107 | { | 107 | { |
108 | #ifdef WIN32 | 108 | #ifdef WIN32 |
@@ -146,7 +146,9 @@ int init_networking(IP ip ,uint16_t port) | |||
146 | 146 | ||
147 | /* Bind our socket to port PORT and address 0.0.0.0 */ | 147 | /* Bind our socket to port PORT and address 0.0.0.0 */ |
148 | ADDR addr = {AF_INET, htons(port), ip}; | 148 | ADDR addr = {AF_INET, htons(port), ip}; |
149 | bind(sock, (struct sockaddr*)&addr, sizeof(addr)); | 149 | if(bind(sock, (struct sockaddr*)&addr, sizeof(addr)) == -1) |
150 | return -1; | ||
151 | |||
150 | return 0; | 152 | return 0; |
151 | 153 | ||
152 | } | 154 | } |