-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/sendgui.cc | 47 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/sendgui.hh | 1 |
3 files changed, 8 insertions, 41 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index 7972c0f..8724efa 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc @@ -71,2 +71,3 @@ int main(int argc, char **argv) } + log_info("Sending command to '%s': %s", GUIADDR, buffer); diff --git a/noncore/net/wellenreiter/daemon/source/sendgui.cc b/noncore/net/wellenreiter/daemon/source/sendgui.cc index 48ad5b8..9e57094 100644 --- a/noncore/net/wellenreiter/daemon/source/sendgui.cc +++ b/noncore/net/wellenreiter/daemon/source/sendgui.cc @@ -10,35 +10,2 @@ -/* Simple dummy for alarm timer */ -static void alarmdummy(int signo) -{ - alarm (0); -} - -/* Connect to given IP on given port */ -int connect_server(int *sock, unsigned int ipaddr, int port) -{ - struct sockaddr_in saddr; - int retval=0; - - *sock = socket (PF_INET, SOCK_STREAM, 0); - saddr.sin_family = PF_INET; - saddr.sin_port = htons (port); - saddr.sin_addr.s_addr = ipaddr; - - signal (SIGALRM, alarmdummy); - siginterrupt (SIGALRM, 1); - - alarm(5); - retval=connect (*sock, (struct sockaddr *) &saddr, sizeof (saddr)); - alarm(0); - - if(retval < 0) - { - close (*sock); - return 0; - } - - return 1; -} - /* Send a string to the GUI */ @@ -48,2 +15,3 @@ int sendgui(const char *string, ...) char buffer[4096]; + struct sockaddr_in saddr; va_list ap; @@ -56,9 +24,9 @@ int sendgui(const char *string, ...) - if(!connect_server(&sock, inet_addr(GUIADDR), GUIPORT)) - { - log_err("Connect to GUI at '%s' failed: %s", GUIADDR, strerror(errno)); - return 0; - } + /* Setup socket */ + sock = socket (AF_INET, SOCK_DGRAM, 0); + saddr.sin_family = AF_INET; + saddr.sin_port = htons(GUIPORT); + saddr.sin_addr.s_addr = inet_addr(GUIADDR); - if(write(sock, buffer, sizeof(buffer)) < 0) + if(sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { @@ -74,2 +42 @@ int sendgui(const char *string, ...) } - diff --git a/noncore/net/wellenreiter/daemon/source/sendgui.hh b/noncore/net/wellenreiter/daemon/source/sendgui.hh index e083704..d9b3fcd 100644 --- a/noncore/net/wellenreiter/daemon/source/sendgui.hh +++ b/noncore/net/wellenreiter/daemon/source/sendgui.hh @@ -16,3 +16,2 @@ -int connect_server(int *, unsigned int, int); int sendgui(const char *string, ...); |