Jagadheesh
Jagadheesh

Reputation: 13

recv failed if socket fd more than 1024 in cpp linux

In my project i am using open close (server and client c++ Linux multithreading ) model every time client create socket file descriptor and send data to server and receive wait for response.in this process after some transactions rec v failed. for this i observed socket file descriptor is more than 1024. but i was set max allowed file descriptors at Linux operating system level 8192. And also i was observed one more thing by using thisis (netstat -an|grep "PORT NUMBER") command socket connections are observed those are less connections (< 300). my connection pool size is 100 only . In this few of connections close_wait state.

How to over come this issue .please suggest me.

Upvotes: 0

Views: 859

Answers (2)

o11c
o11c

Reputation: 16136

1024 is the usual definition of FD_SETSIZE from sys/select.h (on my system, deeply included from bits/typesizes.h)

If you're using select, you should stop and use poll or epoll instead, since they don't require a hard-coded limit at compile-time, only the runtime limit on maximum number of open files.

Upvotes: 1

Sam Varshavchik
Sam Varshavchik

Reputation: 118425

Sounds like you are leaking some other file descriptor, and not necessarily your socket's file descriptor. You're probably leaving some file open, probably. Look into /proc/<pid>/fd, which will list all open file descriptors for the given process.

Upvotes: 0

Related Questions