aboutsummaryrefslogtreecommitdiff
path: root/src/inet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/inet.c')
-rw-r--r--src/inet.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/inet.c b/src/inet.c
index f6c2a6f..dff4bf2 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -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\*-------------------------------------------------------------------------*/
216const char *inet_trybind(p_sock ps, const char *address, unsigned short port, 216const 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/*-------------------------------------------------------------------------*\