Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Connectionless, unconnected" connections

I just started learning about sockets programming, and I've run into a concept I've seen before but was quite confusing to me.

It seems that UDP connections are "connectionless, unconnected" connections.

Isn't "connectionless" and "unconnected" redundant?

Are there then 4 types of connections?

i.e.

  1. connectionless, unconnected
  2. connectionless, connected
  3. connection-oriented unconnected
  4. connection-oriented, connected

And finally, how can a "connectionless, unconnected" connection function? Isn't that an oxymoron? lol

like image 900
node ninja Avatar asked Dec 02 '22 00:12

node ninja


1 Answers

Technically, you can call connect() on a UDP socket. In this case the socket remembers the peer address, so that datagrams can be send using send() or write() syscalls instead of sendto(). Also, it makes the socket receive datagrams only from that peer, datagrams from other peers get discarded.

May be this is what is referred to as "connectionless, connected" socket, meaning connect() call was invoked on a UDP socket.

like image 118
Maxim Egorushkin Avatar answered Dec 04 '22 16:12

Maxim Egorushkin