Connectionless connections, unrelated to each other
I just started learning socket programming and I came across a concept that I had seen before but was quite confusing for me.
It looks like UDP connections are connectionless connections that are not related to each other.
Is "connectionless" and "disconnected" redundant?
Are there 4 types of connections?
i.e.
- connectionless, unrelated
- connectionless, connected
- not bound to connection
- connection-oriented, connected
And finally, how could there be a "contactless, unbound" connection function? Isn't that an oxymoron? lol
source to share
In fact, there is no such thing as a UDP connection. Basically, UDP is a fire and forget protocol where you just send packets of data to some machine (without having to first establish a connection) and hoping that another machine will pick them up (if they do at all).
When you establish a "socket connection" nothing magical happens; the wires between you and your remote client don't change color or anything like that. What happens during the connection is that both parties agree to receive and send data securely over the Internet with this protocol. There is absolutely no need to communicate with anything in order to send and receive information over the Internet, however, connections can guarantee integrity and order (and a few other things) because both machines have agreed to follow a certain method.
I don't know of such a thing as a "contactless, unbound" socket. Whoever told you was probably just trying to emphasize the unrelated aspect of UDP.
source to share
Technically you can call connect()
on a UDP socket. In this case, the socket remembers the peer address, so datagrams can be sent using send()
or write()
syscalls instead sendto()
. In addition, it forces the socket to receive datagrams only from this peer; datagrams from other peers are discarded.
Maybe this is what is called the connectionless socket associated with it, meaning the call connect()
was made to a UDP socket.
source to share