Skip to content

Instantly share code, notes, and snippets.

@OmarMalik
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OmarMalik/8b847439b0cb371736df to your computer and use it in GitHub Desktop.
Save OmarMalik/8b847439b0cb371736df to your computer and use it in GitHub Desktop.
int main(int argc, char **argv)
{
int listenfd, port;
char * root = NULL;
int opt;
while ((opt = getopt(argc, argv, "p:R:")) > 0)
{
switch(opt)
{
case 'p':
port = atoi(optarg);
case 'R':
root = optarg;
break;
}
}
list_init(&memory_list);
listenfd = Open_listenfd(port);
pthread_t ipv6_thread, ipv4_thread;
pthread_create(&ipv4_thread, NULL, &doit, NULL);
pthread_create(&ipv6_thread, NULL, &doit, NULL);
}
void * ipv6_listener()
{
int clientlen, connfd;
struct sockaddr_in clientaddr;
while(1) {
pthread_t thread;
clientlen = sizeof(clientaddr);
connfd = Accept(listenfd, (SA *)&clientaddr, &clientlen);
pthread_create(&thread, NULL, &doit, (void *)connfd);
}
}
void * ipv4_listener()
{
int clientlen;
struct sockaddr_in clientaddr;
while(1) {
pthread_t thread;
clientlen = sizeof(clientaddr);
connfd = Accept(listenfd, (SA *)&clientaddr, &clientlen);
pthread_create(&thread, NULL, &doit, (void *)connfd);
}
}
/*
ssh -L 17857:localhost:17857 yourpid@rlogin.cs.vt.edu
http://localhost:17857/
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment