[[Property:title|Using datagram sockets]]
[[Property:weight|7]]
[[Property:uuid|ba27b7dd-77db-7f6f-9b8c-2a3111d9d432]]
{{note|The example classes discussed in this section appear in the subdirectory ''datagram'' of the example directory. }}

Using datagram sockets implies a few differences from the preceding schemes. You create a [[ref:libraries/net/reference/network_datagram_socket_chart|NETWORK_DATAGRAM_SOCKET]]  or a <eiffel>UNIX_DATAGRAM_SOCKET</eiffel> as before. You do not need to call <eiffel>listen</eiffel>, <eiffel>accept</eiffel> or <eiffel>connect</eiffel>. Once you have created your sockets using the <eiffel>make_client</eiffel> or <eiffel>make_server</eiffel> creation procedure, you can use the <eiffel>send</eiffel> and <eiffel>received</eiffel> routines, specifying the socket to which you want to send, or from which you want to receive. 

The command <eiffel>send</eiffel> takes an argument of type [[ref:libraries/net/reference/datagram_packet_chart|DATAGRAM_PACKET]] , and the query <eiffel>received</eiffel> returns a result of this type. [[ref:libraries/net/reference/datagram_packet_chart|DATAGRAM_PACKET]]  is an heir of class [[ref:libraries/net/reference/packet_chart|PACKET]] , itself an heir of [[ref:libraries/base/reference/array_chart|ARRAY]]  [ [[ref:libraries/base/reference/character_8_chart|CHARACTER]] ]. Class [[ref:libraries/net/reference/datagram_packet_chart|DATAGRAM_PACKET]]  makes it possible, through the query <eiffel>number</eiffel> and the associated command <eiffel>set_number</eiffel>, to associate a packet number with each packet. This compensates for lack of guaranteed sequencing of datagram sockets: the sender can number packets through <eiffel>set_number</eiffel>, and the receiver can check that all packets have been received through <eiffel>number</eiffel>, asking the sender to re-emit missing objects. 

The text of this example is similar to what appears below (in a more general setting involving event-driven computation) for the next example.




