Used to learn socket programming...
git clonse https://github.com/Wonicon/MaybeServer.git
cd MaybeServer
make
The default exectuable filename is server
.
./server root-path port-number
http://www.linuxhowtos.org/C_C++/socket.htm
This site shows basic client and server code, with detailed explanation.
The way it initializes sockaddr_in
structure and uses socket-related system calls is really concise.
http://blog.abhijeetr.com/2010/04/very-simple-http-server-writen-in-c.html
Thanks to this example, I realised that I should call shutdown
, but not only close
to destroy sockets.
Moreover, its way to send requested file is much easier, directly opening the file with 'open' system call.