Skip to content

Instantly share code, notes, and snippets.

@dmateos
Created December 10, 2009 10:46
Show Gist options
  • Save dmateos/253265 to your computer and use it in GitHub Desktop.
Save dmateos/253265 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include "sockio.h"
#include <unistd.h>
void handle_connection(int sd) {
printf("new connection from %d\n", sd);
}
void handle_read(int sd) {
char buffer[1024];
int rcount;
printf("read me from %d\n", sd);
rcount = read(sd, buffer, 1024);
buffer[rcount] = '\0';
printf("%s", buffer);
}
int main(int argc, char *argv[]) {
if(setup_socket_io(handle_connection, handle_read) == -1)
exit(1);
while(1) {
read_poll_io();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment