4 ms·
"UDP connections"? UPD is connection less.
by callesgg 10y ago
"UDP connections"?
UPD is connection less.
- cheez 10y agohttps://golang.org/pkg/net/#UDPConn https://golang.org/pkg/net/#UDPConn
- bryceneal 10y agoYou are right. I believe the "connection" analog exists in Go as a means of implementing a common interface across protocols.
- thwarted 10y agoIt is possible to have a "connected UDP socket". It is one that is already set up with a remote endpoint. if you connect() a SOCK_DGRAM UDP socket to a remote host, you can use send() and recv() as well as sendto() and recvfrom(). If you want. http://beej.us/guide/bgnet/output/html/multipage/connectman.html http://beej.us/guide/bgnet/output/html/multipage/connectman....
- xxpor 10y agoThere's still a lot of state (mostly in firewalls) associated with UDP traffic, and treating it as a connection (even if it isn't technically) can be useful.
- adventureloop 10y agoUDP certainly is connectionless, but that doesn't mean a host can't call `connect` on a UDP scoket. In fact, it is encouraged[1]. I am going to quote the entire paragraph from the RFC, the guidelines document is a very good read if you plan to use UDP. Succinctly, you should `connect` a UDP socket, it can simplify some calls and allows the application to receive ICMP errors Many operating systems also allow a UDP socket to be connected, i.e., to bind a UDP socket to a specific pair of addresses and ports. This is similar to the corresponding TCP sockets API functionality. However, for UDP, this is only a local operation that serves to simplify the local send/receive functions and to filter the traffic for the specified addresses and ports. Binding a UDP socket does not establish a connection -- UDP does not notify the remote end when a local UDP socket is bound. Binding a socket also allows configuring options that affect the UDP or IP layers, for example, use of the UDP checksum or the IP Timestamp option. On some stacks, a bound socket also allows an application to be notified when ICMP error messages are received for its transmissions [RFC1122]. [1]: https://tools.ietf.org/html/rfc5405#section-3.6 https://tools.ietf.org/html/rfc5405#section-3.6