📄 udp.4p
字号:
.\" SCCSID: @(#)udp.4p 8.1 9/11/90.TH udp 4p.SH Nameudp \- Internet User Datagram Protocol.SH Syntax.B #include <sys/socket.h>.br.B #include <netinet/in.h>.PP.B s = socket(AF_INET, SOCK_DGRAM, 0);.SH Description.NXR "UDP".NXS "User Datagram Protocol" "UDP"UDP is a simple, unreliable datagram protocol that is usedto support the SOCK_DGRAM abstraction for the Internetprotocol family. UDP sockets are connectionless and arenormally used with the.PN sendto and.PN recvfrom calls, though the.MS connect 2call can also be used to fix the destination for futurepackets (in which case the .MS recv 2or.MS read 2and .MS send 2or.MS write 2system calls may be used)..PPUDP address formats are identical to those used byTCP. .NXR "UDP" "TCP and"In particular, UDP provides a port identifier in additionto the normal Internet address format. Note that the UDP portspace is separate from the TCP port space (for example, a UDP portmay not be ``connected'' to a TCP port). In addition broadcastpackets can be sent (assuming the underlying network supportsthis) by using a reserved ``broadcast address''; this addressis network interface dependent. The SO_BROADCAST option must beset on the socket for broadcasting to succeed..SH DiagnosticsA socket operation may fail with one of the following errors returned:.TP 15[EISCONN]Try to establish a connection on a socket whichalready has one, or when trying to send a datagram with the destinationaddress specified and the socket already connected..TP 15[ENOTCONN]Try to send a datagram, butno destination address is specified, and the socket has not beenconnected..TP 15[ENOBUFS]The system runs out of memory foran internal data structure..TP 15[EADDRINUSE]An attemptis made to create a socket with a port that has already beenallocated..TP 15[EADDRNOTAVAIL]An attempt is made to create a socket with a network address for which no network interfaceexists..SH See Alsogetsockopt(2), send(2), socket(2) recv(2), intro(4n), inet(4f)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -