Search code examples
csocketsnetwork-programmingudpposix-select

concurrent UDP server using select() call


I am following this example. Only change that I want to make is that instead of having a TCP concurrent server, I want the server to be UDP server.

I was initially getting error message that listen() is not supported, which makes sense. There is no point of having listen() on UDP socket.

Now I am stuck at accept: Operation not supported error message. The line which is causing the error is - newfd = accept(listener,(struct sockaddr *)&remoteaddr,&addrlen);

My question is- how do I do I/O multiplexing on UDP sockets?


Solution

  • Since UDP is NOT connection oriented, you can't do an accept. You have to read from the bound UDP socket, which gives you a packet.