13 #include <netinet/in.h>
14 #include <sys/socket.h>
16 #define REPEATDELAY 350 // ms
17 #define REPEATFREQ 100 // ms
18 #define REPEATTIMEOUT 500 // ms
19 #define RECONNECTDELAY 3000 // ms
25 addr.sun_family = AF_UNIX;
26 strcpy(
addr.sun_path, DeviceName);
45 if ((
f = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0) {
46 if (connect(
f, (
struct sockaddr *)&
addr,
sizeof(
addr)) >= 0)
74 int ret = ready ?
safe_read(
f, buf,
sizeof(buf)) : -1;
76 if (ready && ret <= 0 ) {
77 esyslog(
"ERROR: lircd connection broken, trying to reconnect every %.1f seconds",
float(
RECONNECTDELAY) / 1000);
83 isyslog(
"reconnected to lircd");
89 if (ready && ret > 0) {
93 if (sscanf(buf,
"%*x %x %29s", &count, KeyName) != 2) {
94 esyslog(
"ERROR: unparseable lirc command: %s", buf);
101 Put(LastKeyName,
false,
true);
102 strcpy(LastKeyName, KeyName);
116 Put(KeyName, repeat);
120 Put(LastKeyName,
false,
true);