Domanda

When i create a c++ program using Winsock and send() a HTTP request packet to a hostname(ie: www.blah.com at 223.224.245.233 running on port 80) and the HTTP response is given back to me through recv(), why does the the receiver of my packet need to bind a socket to a port to talk to me, but i don't?

Is it because I initially sent a packet and in that packet it contains information that enables them to send a packet back to me(a response) without me needing to bind a socket to a port?

I'm wondering why multiple computers that talk to each don't need sockets bound to certain ports.

I thought computer communication was like so: (Service on port 80 at 223.224.245.233) sends packet to (Service on port 94 at 223.224.245.234) (Service on port 94 at 223.224.245.234) receives packet from (Service on port 94 at 223.224.245.233)

È stato utile?

Soluzione

why does the the receiver of my packet need to bind a socket to a port to talk to me

It doesn't. It needs to bind a socket to a port to listen for incoming connections. Then you connect to it, then it accepts a connected socket, then it talks to you.

but i don't

There is an automatic bind when you connect.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top