Web Server

What is a server? It is just a process waiting on a network port. It is a porcess that doesn’t exit. Reads and resonds to messages coming to the network port. What is a network port? There are many layers on the network structure. At IP level, every machine has an IP address. Anything sent to an IP has some bytes. OS is what provides sever with the API to read those. So server is an applicaition. A server can only register a port abstraction on the OS. What is a connection? Connection is also at TCP level. A connection is a reference a server has so it can stay connected to many clients. Connection maintains some state. It is opened and closed. Once a connection is opened, the server app gets a socket and the other one gets a socket too. They can read and write to the socket. HTTP is on top of that. Either party can close the socket. The connection is closed then. Some error happen in the server, socket is closed. Network issue, connection is lost. With HTTP, client starts a connection, writes a requesr. Then server writes a response and closed the connection. The connection socket may not be from the OS but from the server app itself. It is what maintains the conneciton state. The server can have a connection pool so it can stay connected to many clients at a time. One client closes, another can join. Each connection could be a thread in some frameworks. Must check out network primitives on C. The server framework is what reads the stuff of the network port and gives it to the custom code writter by the web programmer.