while I was studying Internet Protocols, a question just occurred to me. Typically, we could assign any ports that are not for typical usage (e.g. 80 for HTTP, 443 for HTTPS) to our applications. For example, when I use Node.js Express to build a simple server, I could assign port 5000 to this process like below.
const express = require('express')
const app = express()
const port = 5000
// some code to configure server
app.listen(port, () => {
console.log(`Server is now running on port ${port}`)
})
My Node.js application will listen to port 5000. If my ip is for example 10.10.10.10, then my application will get a request if anyone hits 10.10.10.10:5000. However, if that's a HTTP/HTTPS request, shouldn't the packets come from port 80 / 443? Can someone tell me why it's not the case or why application listening to different ports can receive packets if they indeed come from 80 / 443.
Thank you.
