TCP Service in Control6: Unterschied zwischen den Versionen

Aus Ethersex_Wiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „Control6 TCP Listener This Control6 example implenents a TCP service that listens on port 4444 and echoes any incoming data via syslog. <code> CONTROL_START ON…“)
 
 
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
Control6 TCP Listener
+
This example implenents a TCP service that listens on port 4444 and echoes any incoming data via syslog.
  
This Control6 example implenents a TCP service that listens on port 4444 and echoes any incoming data via syslog.
+
<source lang="c">
 
 
<code>
 
 
CONTROL_START
 
CONTROL_START
  
Zeile 25: Zeile 23:
  
 
CONTROL_END  
 
CONTROL_END  
 +
</source>
  
 
[[Category:Control6_Examples]]
 
[[Category:Control6_Examples]]
 
</code>
 

Aktuelle Version vom 27. August 2011, 13:12 Uhr

This example implenents a TCP service that listens on port 4444 and echoes any incoming data via syslog.

CONTROL_START

ON STARTUP DO
        TCP_LISTEN(4444, message_handler);
END

TCP_HANDLER(message_handler)
        for (;;) {
                if (uip_connected()) {
                        SYSLOG("connected");
                }
                if (uip_newdata ()) {
                        char *ptr = (char *) uip_appdata;
                        ptr[uip_len] = 0;
                        SYSLOG("%s", ptr)
                }
                PT_YIELD(pt);
        }
TCP_HANDLER_END();

CONTROL_END