From 176be1cff269cf27f9ac7cf7de5883b1b5eef755 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Thu, 15 Aug 2013 14:05:15 +0000 Subject: [PATCH] Add the ability to bind listening sockets to addresses, and use this for the /detach IPC socket. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@330 13b04d17-f746-0410-82c6-800466cd88b0 --- source/commands2.c | 2 +- source/network.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/commands2.c b/source/commands2.c index 344134b..3c01975 100644 --- a/source/commands2.c +++ b/source/commands2.c @@ -2576,7 +2576,7 @@ static int create_ipc_socket(void) init_socketpath(); - if ((s = connect_by_number(NULL, &port, SERVICE_SERVER, PROTOCOL_TCP, 0)) < 0) + if ((s = connect_by_number("127.0.0.1", &port, SERVICE_SERVER, PROTOCOL_TCP, 0)) < 0) { bitchsay("Error creating IPC socket: [%d] %s", s, strerror(errno)); return 1; diff --git a/source/network.c b/source/network.c index dd318a8..cad3093 100644 --- a/source/network.c +++ b/source/network.c @@ -466,7 +466,11 @@ int BX_connect_by_number(char *hostn, unsigned short *portnum, int service, int memset(&name, 0, sizeof name); name.sin_family = AF_INET; - name.sin_addr.s_addr = htonl(INADDR_ANY); + + if (hostn) + inet_aton(hostn, &name.sin_addr); + else + name.sin_addr.s_addr = htonl(INADDR_ANY); name.sin_port = htons(*portnum); #ifdef PARANOID