[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] Triggered EV_READ event socket get ENOT Transport endpoint is not connected




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
socklen_t socklen;
struct sockaddr_in client_addr;
socklen = sizeof(client_addr);
retval = getpeername(connfd, (struct sockaddr *)&client_addr, &socklen);
if(retval == -1) perror("getpeername error!\n");

but sometimes, it returns 0.0.0.0:0

and then I notice the error is Transport endpoint is not connected

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?


maybe there is something wrong with libevent?


thanks!