diff options
Diffstat (limited to 'src/inet.c')
-rw-r--r-- | src/inet.c | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -213,8 +213,7 @@ const char *inet_tryconnect(p_sock ps, const char *address, | |||
213 | /*-------------------------------------------------------------------------*\ | 213 | /*-------------------------------------------------------------------------*\ |
214 | * Tries to bind socket to (address, port) | 214 | * Tries to bind socket to (address, port) |
215 | \*-------------------------------------------------------------------------*/ | 215 | \*-------------------------------------------------------------------------*/ |
216 | const char *inet_trybind(p_sock ps, const char *address, unsigned short port, | 216 | const char *inet_trybind(p_sock ps, const char *address, unsigned short port) |
217 | int backlog) | ||
218 | { | 217 | { |
219 | struct sockaddr_in local; | 218 | struct sockaddr_in local; |
220 | const char *err; | 219 | const char *err; |
@@ -231,16 +230,9 @@ const char *inet_trybind(p_sock ps, const char *address, unsigned short port, | |||
231 | addr = (struct in_addr **) hp->h_addr_list; | 230 | addr = (struct in_addr **) hp->h_addr_list; |
232 | memcpy(&local.sin_addr, *addr, sizeof(struct in_addr)); | 231 | memcpy(&local.sin_addr, *addr, sizeof(struct in_addr)); |
233 | } | 232 | } |
234 | sock_setblocking(ps); | ||
235 | err = sock_bind(ps, (SA *) &local, sizeof(local)); | 233 | err = sock_bind(ps, (SA *) &local, sizeof(local)); |
236 | if (err) { | 234 | if (err) sock_destroy(ps); |
237 | sock_destroy(ps); | 235 | return err; |
238 | return err; | ||
239 | } else { | ||
240 | sock_setnonblocking(ps); | ||
241 | if (backlog >= 0) sock_listen(ps, backlog); | ||
242 | return NULL; | ||
243 | } | ||
244 | } | 236 | } |
245 | 237 | ||
246 | /*-------------------------------------------------------------------------*\ | 238 | /*-------------------------------------------------------------------------*\ |