user5155835
user5155835

Reputation: 4742

Is different port used for every request from same client?

I have a web client which has code such as:

for(i = 0; i < 10; i++) {
    $.ajax({
        url: "url",
        type: "GET/POST",
        data: {
            ...
        }
    }).done(function (data) {
    ...
    });
}

So I'm making 10 requests to the same server url (java servlet with doGet, doPost methods)

In this case, will 10 different ports be used at the server side for 10 different 10 requests? Or will those requests share the same server port?

Upvotes: 0

Views: 888

Answers (1)

David Hoelzer
David Hoelzer

Reputation: 16381

Assuming that these requests are made successively, this will result in 10 connections from the client to the server.

The client port will be different, likely incrementing, between port 1025 and port 65535. The server port will be the same; port 80 or 443, for example.

The client IP/client port/serverIP/server port make up the IP port pair that are used to key the connection, allowing the server to distinguish one from the other. Of course, over TCP, the sequence number is also involved in keying the communication, but the IP port pair is the primary distinguishing factor for the TCP/IP stack.

Upvotes: 1

Related Questions