in my program, I register a EV_READ event conn_ev for connfd in libevent event loop.
when this event is triggered, I use getpeername to get the IP/PORT address of the peer
but sometimes, it returns 0.0.0.0:0 and then I notice the error is but recv(connfd,buf,..) returns a 1273 , which means it receives 1273 bytes. One possibility is the socket connfd is closed locally. Indeed, I have a function which call event_del(conn_ev) and close(connfd) , and some other events sometimes call this function. But if the function is called, the event is deleted and the connfd is closed. How can the event be triggered? if the connection is ended by the other side(the peer), how can recv() get bytes? and how can the event be triggered? thanks! |