All pastes #951926 Raw Edit

old route

public c v1 · immutable
#951926 ·published 2008-03-21 19:44 UTC
rendered paste body
#include <sys/socket.h>#include <sys/types.h>#include <arpa/inet.h>#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <time.h>#include <string.h>#include <ctype.h>#include <netinet/in.h>#include <sys/wait.h>#include <signal.h>#include <poll.h>#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