Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Added daytime.c example
Browse files Browse the repository at this point in the history
  • Loading branch information
rxi committed Sep 5, 2014
1 parent 6778364 commit 3fed186
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions example/daytime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>
#include "dyad.h"

/* Conneccts 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, "wolfnisttime.com", 13);

while (dyad_getStreamCount() > 0) {
dyad_update();
}

dyad_shutdown();
return 0;
}

0 comments on commit 3fed186

Please sign in to comment.