Skip to content

Instantly share code, notes, and snippets.

@bonfus
Created February 3, 2017 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonfus/739ef2789e806208594596397fe7027e to your computer and use it in GitHub Desktop.
Save bonfus/739ef2789e806208594596397fe7027e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include "dyad.h"
/* Connects to a daytime server and prints the response */
static void onConnect(dyad_Event *e) {
printf("connected: %s\n", e->msg);
}
static void onError(dyad_Event *e) {
printf("error: %s\n", e->msg);
}
static void onData(dyad_Event *e) {
printf("%s", e->data);
}
int main(void) {
dyad_Stream *s;
dyad_init();
s = dyad_newStream();
dyad_addListener(s, DYAD_EVENT_CONNECT, onConnect, NULL);
dyad_addListener(s, DYAD_EVENT_ERROR, onError, NULL);
dyad_addListener(s, DYAD_EVENT_DATA, onData, NULL);
dyad_connect(s, "www.libero.it", 80);
while (dyad_getStreamCount() > 0) {
dyad_update();
}
dyad_end(s);
dyad_connect(s, "www.libero.it", 80);
while (dyad_getStreamCount() > 0) {
dyad_update();
}
dyad_shutdown();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment