Pergunta

I got a trainee in the company I work for. We are currently working on a JS interface that communicates through websocket with a C/Lang server. My trainee asked me a very good question this morning.

I quote :

"I understand the system of sending and receiving messages, but how the computer actually receives and forwards the message to the running code".

I tried to explain how, but I failed as I don't know how to softly introduce port interactions.

The problem is that I feel that the trainee doesn't understand. I know that these kind of questions can get stuck into the head of a programmer and make him/her more hesitant in front of code and I don't want that for my trainee.

Can someone with good explanation skills help me make a simple, yet complete, answer to this question?

Any help would be much appreciated.

Foi útil?

Solução

I always think of it as:

  • The port is an address on the incoming packet
  • The operating system has been told to put any messages coming into the computer with that port address to a particular place in memory
  • The program knows to look at that memory address to find its messages
  • The bindings are a series of processes in your program telling the operating system, the program etc where and what to look out for, which is why you need more than 1 to get everything working. Outgoing is pretty much the same but in reverse
Licenciado em: CC-BY-SA com atribuição
scroll top