This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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