author | mjm <mjm> | 2002-11-13 21:57:18 (UTC) |
---|---|---|
committer | mjm <mjm> | 2002-11-13 21:57:18 (UTC) |
commit | 9c48a8f9d70af68b9e57a82cda637ad8c2abf5c9 (patch) (unidiff) | |
tree | 427d7e9a07573d295eeabf926d1664ec955331fd /noncore/net/wellenreiter/daemon/source | |
parent | d3301ad9a74fdf693551bd70bc3cf34b311eaa49 (diff) | |
download | opie-9c48a8f9d70af68b9e57a82cda637ad8c2abf5c9.zip opie-9c48a8f9d70af68b9e57a82cda637ad8c2abf5c9.tar.gz opie-9c48a8f9d70af68b9e57a82cda637ad8c2abf5c9.tar.bz2 |
sendgui.cc is now udp based
Diffstat (limited to 'noncore/net/wellenreiter/daemon/source') (more/less context) (ignore whitespace changes)
-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) | |||
71 | } | 71 | } |
72 | log_info("Sending command to '%s': %s", GUIADDR, buffer); | ||
72 | 73 | ||
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 @@ | |||
10 | 10 | ||
11 | /* Simple dummy for alarm timer */ | ||
12 | static void alarmdummy(int signo) | ||
13 | { | ||
14 | alarm (0); | ||
15 | } | ||
16 | |||
17 | /* Connect to given IP on given port */ | ||
18 | int connect_server(int *sock, unsigned int ipaddr, int port) | ||
19 | { | ||
20 | struct sockaddr_in saddr; | ||
21 | int retval=0; | ||
22 | |||
23 | *sock = socket (PF_INET, SOCK_STREAM, 0); | ||
24 | saddr.sin_family = PF_INET; | ||
25 | saddr.sin_port = htons (port); | ||
26 | saddr.sin_addr.s_addr = ipaddr; | ||
27 | |||
28 | signal (SIGALRM, alarmdummy); | ||
29 | siginterrupt (SIGALRM, 1); | ||
30 | |||
31 | alarm(5); | ||
32 | retval=connect (*sock, (struct sockaddr *) &saddr, sizeof (saddr)); | ||
33 | alarm(0); | ||
34 | |||
35 | if(retval < 0) | ||
36 | { | ||
37 | close (*sock); | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | return 1; | ||
42 | } | ||
43 | |||
44 | /* Send a string to the GUI */ | 11 | /* Send a string to the GUI */ |
@@ -48,2 +15,3 @@ int sendgui(const char *string, ...) | |||
48 | char buffer[4096]; | 15 | char buffer[4096]; |
16 | struct sockaddr_in saddr; | ||
49 | va_list ap; | 17 | va_list ap; |
@@ -56,9 +24,9 @@ int sendgui(const char *string, ...) | |||
56 | 24 | ||
57 | if(!connect_server(&sock, inet_addr(GUIADDR), GUIPORT)) | 25 | /* Setup socket */ |
58 | { | 26 | sock = socket (AF_INET, SOCK_DGRAM, 0); |
59 | log_err("Connect to GUI at '%s' failed: %s", GUIADDR, strerror(errno)); | 27 | saddr.sin_family = AF_INET; |
60 | return 0; | 28 | saddr.sin_port = htons(GUIPORT); |
61 | } | 29 | saddr.sin_addr.s_addr = inet_addr(GUIADDR); |
62 | 30 | ||
63 | if(write(sock, buffer, sizeof(buffer)) < 0) | 31 | if(sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) |
64 | { | 32 | { |
@@ -74,2 +42 @@ int sendgui(const char *string, ...) | |||
74 | } | 42 | } |
75 | |||
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 @@ | |||
16 | 16 | ||
17 | int connect_server(int *, unsigned int, int); | ||
18 | int sendgui(const char *string, ...); | 17 | int sendgui(const char *string, ...); |