× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




The error is CPE3452 - "Too many open files for this process." After I cancel the program, even my PING's sometimes fail to servers that I can ping under other jobs.

Sounds like the sockets aren't closing. (PING uses sockets as well, so if your job is out of available sockets, PING won't work either.)

I'm using the close(SktID) API with no -1 return conditions. Does anyone know if close(SktID) doesn't actually work for sockets?

If the close() API doesn't work with sockets (as you suggest) then the following code should produce an error, right?

     H dftactgrp(*NO)
      /copy socket_h
     d SktId           s             10I 0
     d x               s             10I 0

      /free

       for x = 1 to 5000;

          SktId = socket(AF_INET: SOCK_STREAM: IPPROTO_IP);
          if (SktId < 0);
              dsply ('failed at ' + %char(x));
              leave;
          endif;
          callp close(SktId);

       endfor;

       *inlr = *on;

      /end-free

After all, your job can only handle 255 open descriptors, and several are used by the operating system. You'd be lucky to get 200 open -- yet that code tries to open 5000.

However, I don't get any errors when I run it. Therefore, the close() API must be doing it's job.

Of course, it could be different after a connection is made, right? So let's try connecting 5000 times in a loop....

     H dftactgrp(*NO)
      /copy socket_h
     d SktId           s             10I 0
     d x               s             10I 0
     D connto          ds                  likeds(sockaddr_in)

      /free

       for x = 1 to 5000;

          SktId = socket(AF_INET: SOCK_STREAM: IPPROTO_IP);
          if (SktId < 0);
              dsply ('failed at ' + %char(x));
              leave;
          endif;

          connto = *allx'00';
          connto.sin_family = AF_INET;
          connto.sin_port   = 23;
          connto.sin_addr   = INADDR_LOOPBACK;

          if (connect(SktId: %addr(Connto): %size(Connto)) < 0);
              dsply ('conn failed at ' + %char(x));
              callp close(SktId);
              leave;
          endif;

          callp close(SktId);

       endfor;

       *inlr = *on;

      /end-free

This code also runs without any errors on my system. Granted, it takes a lot longer than the previous example (because it builds so many connection attempts!) but it doesn't have any problem with running out of descriptors.

I guess the difference could be that I'm connecting to a loopback, and you're connecting to a different computer. Okay, I'll try changing the connection request to look like this:

      connto = *allx'00';
      connto.sin_family = AF_INET;
      connto.sin_port   = 23;
      connto.sin_addr   = inet_addr('192.168.5.1');

(That's a separate computer on my LAN). When I run this, I also get no errors. Clearly, the close() API is serving it's purpose in closing the socket.

Is it possible that there's a bug in your code that's causing it to bypass the close() API?

Or, perhaps your prototype for the close() API is incorrect?

If you use netstat *cnn, does it show that the sockets are closing?

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.