problem with lots of open sockets


 
Thread Tools Search this Thread
Top Forums Programming problem with lots of open sockets
# 1  
Old 05-10-2009
problem with lots of open sockets

I'm programming in C with lots of sockets, (asynchronous handling), and for a while it goes ok, but after a while it starts to hang, or not get complete connections anymore.

checking my router, i see that i get nat tables overflow and even my DNS cacher seems to be having serious issues...

I'm wondering if there are limits, or conventional rules that apply to the number of open sockets, or something like that. (currently i've set this to 200, and now i don't get that much of problems, but after a while it does get problematic.)

Maybe i'm not shutting them down properly? (close() should be sufficient? no?) Is there a way to test that? (could i test this with periodically checking netstat? or some easier way?)

Does anyone have a suggestion or some info on this officious rules about max connections?


thanks for the help, in advance.
# 2  
Old 05-10-2009
You have some threaded app that has lots of open sockets?

How are you assigning port numbers?
# 3  
Old 05-11-2009
oh, it's not threaded, it's a single thread that uses non-blocking and select to find out if something is to be done.

I'm not tracking port numbers at all. I'm just accepting TCP connections and connecting TCP connections. do i need to do something with port numbers? all the TCP connections have a different fd, so that's not really a problem, is it?

i did make an eventing structure that holds the addrinfo and fd and other stuff
# 4  
Old 05-11-2009
Okay. There is a limit to the number of open "fd" file descriptors that a process can have. What closes those file descriptors?

If your process is hanging it has to have reached some resource limit. Or there is a race condition.

There is getrusage()/getrlimit() - they let you track and report all of the resources the process is using. I would suggest instrumenting your code with that, have it report all of the resources getrusage will show on your system - write it to a file with timestamps for each entry.

Start there.
# 5  
Old 05-11-2009
thanks, that's exactly the sort of thing i was looking for, you've helped me a great deal. i'll post some results later on!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the number of open sockets weblogic

Hi, i am trying to getting the total number of currently open sockets, so i can make an IF statement to see if its over 300 and send a alert. I looked in this page docs.oracle.com/cd/E13222_01/wls/docs81/admin_ref/admin_refIX.html But i didnt find something to get the number of open... (0 Replies)
Discussion started by: axeelcs
0 Replies

2. Shell Programming and Scripting

How to rename lots of files with find?

Can someone help me with this script. I have a bunch of files like this: "2209OS_02_Code" "2209OS_03_Code" "2209OS_04_Code" "2209OS_05_Code" "2209OS_06_Code" "2209OS_07_Code" "2209OS_08_Code" "2209OS_09_Code" "2209OS_10_Code" "2209OS_10_video" and I want to rename them to be like this: ... (2 Replies)
Discussion started by: siegfried
2 Replies

3. Programming

help: problem with sockets write/read

I am trying to make a server and client, the client will choose between some options and the server will react accordingly. After a some reads and writes that work the server needs to read from client an INT i use this: read(newSd,&k,sizeof(int));But even if all the other times there was no... (1 Reply)
Discussion started by: theSling
1 Replies

4. Shell Programming and Scripting

Lots of sed

Hi, I have 200 lines of sed commands in a shellscript sed s/TSTARTO2GPRSEVENTAPNACCSUM_1/TSTARTO2GPRSEVENTAPNACCSUM_24/g sed s/O2GPRSEVENTAPNACCSUM_1/O2GPRSEVENTAPNACCSUM_24/g sed s/TENDO2GPRSEVENTAPNACCSUM_1/TENDO2GPRSEVENTAPNACCSUM_24/g sed s/BSTARTO2EVENTITEM_1/BSTARTO2EVENTITEM_24/g... (6 Replies)
Discussion started by: legolad
6 Replies

5. UNIX for Dummies Questions & Answers

is there any problem with functions and sockets?

hi I am writing a client-server program and the functions I've written on the server are never executed. even something as easy as typing hello does not. is there something to be taken into account to use functions? I appreciate any information (2 Replies)
Discussion started by: oticeip
2 Replies

6. IP Networking

netstat showing lots of errors

Hi, I have a server which receive lots of events to it and when I do netstat -Ie1000g0, I'm seeing the errors as below. Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue e1000g0 1500 abc-1.com abc-1.com 3093708246 12757 92069412 0 0 0 If anyone could direct me to right... (3 Replies)
Discussion started by: mohzub
3 Replies

7. Shell Programming and Scripting

Lots of logs to move....don't remove if open

I have a ksh script that currently moves a day's worth of log files (about 15,000) files to a different directory. The issue is that about 100 of these files are still open for write when this happens. I need an efficient way to ensure that these files aren't open without doing an lsof on each... (7 Replies)
Discussion started by: nestafaria
7 Replies

8. Programming

Problem in file transfer using sockets

Hai Friends I am writing a c program to transfer files from one system to another using TCP/IP socket programming.. My Recieve Program #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> extern int errno; extern char *sys_erlist; void... (2 Replies)
Discussion started by: collins
2 Replies

9. Red Hat

Lots of questions about linux.

I am about 2 months new to Linux, and have only limited experience with PCLinuxOS, (kde) and Redhat. I am installing the latest version of PClinuxOS on my wife's PC right now but running into a problem I dont understand. I have never seen it before so i thought i'd ask how I can get around it.... (1 Reply)
Discussion started by: Methal
1 Replies

10. UNIX for Dummies Questions & Answers

Deleting lots of files.....

Hi All, Thanks in advance for reading and any posts... I have to delete a lot of files (about 6 pages of a4 (ls -ltr)) but I have to keep some as well. I would normally do an rm * to get rid of them all, but thats not what I want to do. Is there anyway I could rm * but add in a list of... (8 Replies)
Discussion started by: B14speedfreak
8 Replies
Login or Register to Ask a Question