#include #include #include #include #include #include #include #include #include #include #include #include #include #define WAN_IPADDR 127.0.0.1 /* this will be our dummy server for now */ #define WAN_PORT 3490 /* so we can use the old example server */ #define LAN_IPADDR notused #define LAN_PORT 1111 /* change as necessary */ #define WAN 0 #define LAN 1 #define NFD 2 /* number of file descriptors to poll */ char* ParseMessage(char* rawMessage) /* no specs on the actual translation yet, so just UPPERCASING for now */ { char temp[1024] = {0}; int i; for ( i=0; i < strlen(rawMessage); i++ ) { temp[i] = toupper(rawMessage[i]); } return temp; } int main(int argc, char *argv[]) { struct pollfd pfd[NFD]; //NFD-element array of polled file descriptors int fd_WAN, fd_LAN; //file descriptors for reading from WAN side, writing to LAN side int err, slen; //return vals, etc struct sockaddr saddr_lan, saddr_wan; //char testmsg[] = "this is the end of the world as we know it"; //printf("%s\n", ParseMessage(testmsg)); while (1) { /* Poll on both the WAN side (for new data) and LAN side (for new client connections) */ err = poll(pfd, NFD, 0); if (err < 0) { perror("poll failed"); fprintf(stderr, "\r"); } else if (err > 0) { if (pfd[0].revents == POLLIN) { /* new connection */ slen = sizeof(saddr_wan); nsd = accept(sd, (struct sockaddr *)&saddr_wan, &slen); //? } } return 0; } //END MAIN