c - udp socket buffer becomes full after calling recvmsg followed by epoll_wait() -


i getting issue udp server socket buffer getting filled up. once buffer full, packets getting dropped. socket buffer size monitored "netstat -anp | grep udp". udp server calls epoll_wait() followed recv_msg(). it's non-blocking socket.

code snippet given below -

struct epoll_event ev = {(unsigned int)0}; ev.events = (unsigned int) (epollin | epollet); ev.data.fd = isockfd; int m_sdepoll = epoll_create(1);  if(epoll_ctl(m_sdepoll, epoll_ctl_add, isockfd, &ev)<0) {     cout << "epoll insertion error sd  : " << isockfd << endl;; }  while( 1 ) {     struct epoll_event events[1];     int noevt = epoll_wait(m_sdepoll, events, 1 , -1);     if(noevt<0)     {         cout << "epoll_wait error no : "<< endl;         continue;     }     for(int i=0; i<noevt; i++)     {         int sd = events[i].data.fd;           int recv_bytes = recvmsg(sd, &msg, 0);      } // end of loop } 

the problem fixed ( i.e socket buffer doesn't fillup ) if recvmsg called in while loop till eagain found before going next descriptor.

any idea why socket buffer gets fill when each event received epoll_wait() single message read

it's getting late i'm at, i'll try make myself understood :)

i refer man pages epoll, can found on linux.die.net example. epoll, when used epollet edge triggered (the et in epollet). means trigger on change in state. if receive multiple messages read first 1 before calling epoll_wait() infinite timeout have dead-locked man page describes.

to summarize: since epoll_wait waiting change (from none messages) there messages available, state transition , thereby event never occur.

edit: stumbled upon this answer similar question.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -