はコネクションレスの、信頼性の低いデータパケットサービスである。 パケットは到着前に並び替えられたり複製されたりする。 UDP
は転送エラーを検出するためにチェックサムを生成・チェックする。
-When a UDP socket is created, its local and remote addresses are
-unspecified. Datagrams can be sent immediately using \fBsendto\fP(2) or
-\fBsendmsg\fP(2) with a valid destination address as an argument. When
-\fBconnect\fP(2) is called on the socket, the default destination address is
-set and datagrams can now be sent using \fBsend\fP(2) or \fBwrite\fP(2) without
-specifying a destination address. It is still possible to send to other
-destinations by passing an address to \fBsendto\fP(2) or \fBsendmsg\fP(2). In
-order to receive packets, the socket can be bound to a local address first
-by using \fBbind\fP(2). Otherwise, the socket layer will automatically assign
-a free local port out of the range defined by
-\fI/proc/sys/net/ipv4/ip_local_port_range\fP and bind the socket to
-\fBINADDR_ANY\fP.
+UDP ソケットが生成されるとき、 ローカルアドレスやリモートアドレスは指定されない。 正しい行き先アドレスを引数として \fBsendto\fP(2) や
+\fBsendmsg\fP(2) を呼べば、データグラムはただちに送信される。 ソケットに対して \fBconnect\fP(2)
+を呼ぶと、デフォルトの行き先アドレスが設定され、 \fBsend\fP(2) や \fBwrite\fP(2)
+を使って、行き先アドレスの指定なしにデータグラムを送信できるようになる。 この場合でも、行き先アドレスを \fBsendto\fP(2) や
+\fBsendmsg\fP(2) に渡せば、デフォルト以外のアドレスに送信可能である。 パケットを受信するために、まずソケットを \fBbind\fP(2)
+を用いてローカルなアドレスにバインドさせることもできる。 そうでない場合は、ソケット層は自動的に
+\fI/proc/sys/net/ipv4/ip_local_port_range\fP で定義されている範囲の外で空いているローカルなポートを割り当て、
+ソケットを \fBINADDR_ANY\fP にバインドする。
受信動作はパケットを一つだけ返す。渡したバッファよりもパケットが 小さければ、そのパケットの大きさのデータだけが返される。
逆にバッファよりも大きい場合はパケットは丸められ、 \fBMSG_TRUNC\fP フラグがセットされる。 \fBMSG_WAITALL\fP