Skip to content

kishanps/Proxyserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Proxyserver

Proxy server implementation

Compile instructions Compile with -lpthread for eg gcc proxyserver.c -lpthread -o proxy

Usage sample Usage: proxy -l -f where local port is the port for proxyserver and forward port is the remote server port no. local and forward port are optional, in their absence they take the values 1099, 5000 resp For eg proxy -l 1099 -f 5000

Impl notes

  1. Creates a server socket ready for accept and when client connects, it establishes a connection to the actual server and keeps the client and server socket pair in the server datastr.
  2. Any data from the client is written to the server socket and response from the server is written back to the client
  3. Uses epoll model to handle the different socket for multiple clients. Chose epoll over other models (like fork) since the stats have to be computed for all client connections cumulative.
  4. Was planning to use timerfd_create and settimer_fd to link a periodic 1sec timer event to the same epoll but couldnt find the <sys/timerfd.h> in my IDE, so had to use another thread with sleep impl to count stats. That necissitates the use of stats lock to take care of access btw the stats thread and main epoll thread.

About

Proxy server implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages