Persistent TCP Connection: Unterschied zwischen den Versionen
Kiwi (Diskussion | Beiträge) |
Dg9oaa (Diskussion | Beiträge) |
||
(Eine dazwischenliegende Version von einem anderen Benutzer wird nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | |||
=== Persistent TCP Connection in Control6 Script === | === Persistent TCP Connection in Control6 Script === | ||
− | + | gummi:~# | |
− | gummi:~# | + | gummi:~# socat stdio tcp4-listen:4444 |
− | gummi:~# socat stdio tcp4-listen:4444 | + | 0070-01-01 00:00 -- pc_counter=2 |
− | 0070-01-01 00:00 -- pc_counter=2 | + | 0070-01-01 00:00 -- pc_counter=7 |
− | 0070-01-01 00:00 -- pc_counter=7 | + | 0070-01-01 00:00 -- pc_counter=12 |
− | 0070-01-01 00:00 -- pc_counter=12 | + | 0009-07-31 00:54 -- pc_counter=14 |
− | 0009-07-31 00:54 -- pc_counter=14 | + | 0009-07-31 00:54 -- pc_counter=19 |
− | 0009-07-31 00:54 -- pc_counter=19 | + | ... |
− | ... | + | |
− | |||
− | |||
− | |||
<source lang="text"> | <source lang="text"> | ||
CONTROL_START | CONTROL_START | ||
+ | ECMD_GLOBAL(pc_counter, 0); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
TCP_HANDLER_PERSIST(message_handler) | TCP_HANDLER_PERSIST(message_handler) | ||
Zeile 35: | Zeile 26: | ||
THREAD_END(send_value) | THREAD_END(send_value) | ||
− | THREAD_START(send_value) | + | ON STARTUP DO |
+ | TCP_CONNECT(10.49.5.120, 4444, message_handler); | ||
+ | dnl (IP Address, Port, Handler-Name ) | ||
+ | |||
+ | THREAD_START(send_value) | ||
+ | END | ||
CONTROL_END | CONTROL_END | ||
+ | |||
</source> | </source> | ||
− | + | ||
− | |||
[[Category:Control6 Examples]] | [[Category:Control6 Examples]] |
Aktuelle Version vom 20. Oktober 2009, 15:18 Uhr
Persistent TCP Connection in Control6 Script
gummi:~# gummi:~# socat stdio tcp4-listen:4444 0070-01-01 00:00 -- pc_counter=2 0070-01-01 00:00 -- pc_counter=7 0070-01-01 00:00 -- pc_counter=12 0009-07-31 00:54 -- pc_counter=14 0009-07-31 00:54 -- pc_counter=19
...
CONTROL_START
ECMD_GLOBAL(pc_counter, 0);
TCP_HANDLER_PERSIST(message_handler)
for (;;) {
TCP_SEND("%04d-%02d-%02d %02d:%02d -- pc_counter=%d\n", CLOCK_YEAR(), CLOCK_MONTH(), CLOCK_DAY(), CLOCK_HOUR(), CLOCK_MIN(), pc_counter);
WAIT(5)
}
TCP_HANDLER_END();
THREAD(send_value)
pc_counter ++;
WAIT(1)
THREAD_END(send_value)
ON STARTUP DO
TCP_CONNECT(10.49.5.120, 4444, message_handler);
dnl (IP Address, Port, Handler-Name )
THREAD_START(send_value)
END
CONTROL_END