0

My understanding regarding network model communication:

Application layer:

1. HTTP(Not Persistent or stateless): For exchanging messages like get, post, put etc. Here connection is made to webserver and disconnected after sending response. So server will not keep track of the previous requests.

2. Websockets(Persistent or statefull): For creating a communication channel that will be open to exchange data. Here we can keep track of the previous requests. Like we can know how many users are currently connected to our server.

Transport layer:

TCP(Persistant and Statefull): Will let the server know to which application to connect using port number. Both HTTP and web sockets will work upon this layer.

Considering working with HTTP and TCP:

  1. I make a HTTP request from browser(application layer):
  2. Connects to web server sends all files requested and also makes a TCP connection with the application(transport layer).
  3. After sending response it's disconnected.

My confusion:

I got totally confused when I heard, read that TCP is Statefull and Persistant connection.

Q1. Now after step three is browser still connected to webserver because of TCP?

Q2. Is the context object we get in server side in c# code is the complete request packet with HTTP info, TCP info, function to invoke or controller to invoke in MVC etc?

Q3. If client and server are still connected with TCP. Then on next HTTP request does it will use the available TCP connection or will create new TCP and HTTP connection? Why can't it use previous TCP to communicate? Or TCP will be destroyed after HTTP? Or what's happening?

Nithin B
  • 601
  • 1
  • 9
  • 26
  • 2
    In a normal use case (i.e. NOT using websockets), the TCP/IP connection from the web browser to the web server is NOT kept open. The browser opens the TCP connection to the server, sends the request, waits for the complete response, and then closes the TCP connection completely. – Joe Irby Mar 16 '17 at 21:42
  • 2
    To elaborate a little more: Q1 - nope! Q2 - yes, the Context object is basically a wrapper to provide you with ways to get at the various data elements of the HTTP request. In addition, it also contains references to some ASP.Net abstract concepts that are also logically attached to a request, such as the Session object. Q3 - every time you make a new http request, the browser typically opens a new TCP connection, and then immediately destroys that connection as soon as it's done getting whatever it wanted from the web server. – Joe Irby Mar 16 '17 at 21:49
  • @JoeIrby Thanks for the clarification man. If you had wrote it as an answer I would have marked it as one. Any way thanks – Nithin B Mar 17 '17 at 02:54

0 Answers0