Created
December 10, 2009 10:46
-
-
Save dmateos/253265 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <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