UDP server methods

Programming a UDP server is a bit different than TCP. TCP requires managing a socket for each peer connection. With UDP, our program only needs one socket. That one socket can communicate with any number of peers.

While the TCP program flow required us to use listen() and accept() to wait for and establish new connections, these functions are not used with UDP. Our UDP server simply binds to the local address, and then it can immediately start sending and receiving data.

The program flow of a TCP Server compared to a UDP Server is as follows:

With either a TCP or UDP server, we use select() when we need to check/wait for incoming data. The difference is that a TCP Server using select() is likely monitoring many separate sockets, while a UDP Server often only needs to monitor one socket. If your program uses both TCP and UDP sockets, you can monitor them all with only one call to select().

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.221.0