1

Almost every definition of socket that I've seen, relates it very closely to the term endpoint:

wikipedia:

A network socket is an internal endpoint for sending or receiving data at a single node in a computer network. Concretely, it is a representation of this endpoint in networking software

This answer:

a socket is an endpoint in a (bidirectional) communication

Oracle's definition:

A socket is one endpoint of a two-way communication link between two programs running on the network

Even stackoverflow's definition of the tag 'sockets' is:

An endpoint of a bidirectional inter-process communication flow

This other answer goes a bit further:

A TCP socket is an endpoint instance

Although I don't understand what "instance" means in this case. If an endpoint is, according to this answer, a URL, I don't see how that can be instantiated.

garci560
  • 2,993
  • 4
  • 25
  • 34
  • https://en.wikipedia.org/wiki/Communication_endpoint – Oliver Charlesworth Nov 25 '17 at 17:51
  • @OliverCharlesworth Thanks, but that doesn't help clarifying the difference – garci560 Nov 25 '17 at 17:52
  • 1
    The difference is akin to "what is the difference between a vehicle and a car?" - a car is a particular type of vehicle. – Oliver Charlesworth Nov 25 '17 at 17:55
  • @OliverCharlesworth If sockets are to endpoints what cars are to vehicles, are other types of endpoints besides sockets? – garci560 Nov 25 '17 at 17:57
  • The meaning of the term "_endpoint_" clearly depends on the context. For example, if you are referring to cabling, it means the physical host interface at the end of the cabling. If you are referring to ICMP, it is the IP module inside a host. If you are referring to a transport protocol, e.g. TCP, then it is a socket. – Ron Maupin Nov 25 '17 at 18:27
  • @Tgilgul That's one of the links in my question – garci560 Nov 25 '17 at 20:04
  • Does this answer your question? [What is the difference between a port and a socket?](https://stackoverflow.com/questions/152457/what-is-the-difference-between-a-port-and-a-socket) – Ron Maupin Sep 12 '20 at 16:43

3 Answers3

4

"Endpoint" is a general term, including pipes, interfaces, nodes and such, while "socket" is a specific term in networking.

Zac67
  • 2,761
  • 1
  • 10
  • 21
2

IMHO - logically (emphasis added) "socket" and "endpoint" are same, because they both are concatenation of an Internet Address with a TCP port. Strictly technically speaking in core-networking, there is nothing like "endpoint", there is only "socket". Go on, read more below...

As @Zac67 highligted, "socket" is a very specific term in networking - if you read TCP RFC (https://www.rfc-editor.org/rfc/rfc793) then you won't find even a single reference of "endpoint", it only talks about "socket". But when you come out of RFC world, you will hear a lot about "endpoint".

Now, they both talk about combination of IP address and a TCP port, but you can't say someone that "please give me socket of your application", you will say "please give me endpoint of your application". So, IMHO the way someone can understand difference between Socket and Endpoint is - even though both refer to combination of IP address and TCP port, but you use term "socket" when you are talking in context of computer processes or in context of OS, otherwise when talking with someone in general you will use "endpoint".

Community
  • 1
  • 1
hagrawal7777
  • 14,103
  • 5
  • 40
  • 70
0

I am a guy coming from embedded systems world and low level things, Endpoint is a hardware buffer constructed at the far end of your machine, what does that mean?

YourMachine <---------------> Device
[Socket]    ----------------> [Endpoint]
[Endpoint]  <---------------- [Socket]

Both sockets and endpoints are endpoints but socket is an endpoint that resides on the sender which here your machine[Socket is a word used to distinguish between sender and receiver]

OK, now that we know it is a buffer, what is the relation between buffers and networking?

Windows

When you create a socket on Windows, the OS returns a handle to that socket, in fact socket is actually a kernel object, so in Windows when you create a kernel object the returned value is a handle which is used to access that object, usually handles are void* which is then casted into numerical value that Windows can understand, now that you have access to socket kernel object, all IO operations are handled in the OS kernel and since you want to communicate with external device then you have to reach kernel first and the socket is exactly doing this, in other words, socket creates a socket object in the kernel = creates an endpoint in the kernel = creates a buffer in the kernel, that buffer is used to stream data through wires later on using OS HAL(Hardware abstraction layer) and you can talk to other devices and you are happy

Now, if the other device doesn't have communication buffer = endpoint, then you can't communicate with it, even if you open a socket on your end, it has to be two way data communication = Send and Receive

Another example of accessing IO peripheral is accessing RAM (Main memory), two ways of accessing RAM, either you access process stack or access process heap, the stack is not a kernel object in fact you can access stack directly without reaching OS kernel, simply by subtracting a value from RSP(Stack pointer register), example:

; This example demonstrates how to allocate 32 contiguous bytes from stack on Windows OS
; Intel syntax
StackAllocate proc
    sub rsp, 20h
    ret
StackAllocate endp 

Accessing heap is different, the heap is a kernel object, so when you call malloc()/new operator in your code a long call stack is called through windows code, the point is reaching RAM requires kernel help, the stack allocation above is actually not reaching RAM, all I did is subtracting a number of an existing value in RSP which is inside CPU so I did not go outside, the heap object in kernel returns a handle that Windows use to manage fragmented memory and in the end returns a void* to that memory

Hope that helped

Ahmad Gon
  • 1
  • 1