Re: AW: Still much more than 350 sockets needed!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wiese, Hendrik writes:
 > > 
 > > > Hello again,
 > > >  
 > > > we still need to know how to increase the maximum number of
 > > > possible open sockets per IP address! Here we got the problem
 > > > that no more than 350 sockets are possible. On another Linux
 > > > (based on LFS) it is no problem to open far more than 5.000
 > > > connections on the same way. So we know that it is possible.
 > > > So how can we break this limitation? Some kind of sysctl?
 > > > Kernel patch needed? Anything else?
 > > >  
 > > > It's urgent, so any kind of help would be greatly appreciated.
 > > >  
 > > > Thanks a lot!!!
 > > >  
 > > > regards,
 > > > H. Wiese
 > > > 
 > > 
 > > My /proc/net/sockstat says that i have 541 used sockets on a standard 
 > > laptop???
 > > 
 > > could you a simplified version of the code to create all these sockets
 > 
 > > the way you do it?
 > > 
 > > That would allow perhaps more people to understand the problem/see for
 > 
 > > themselves.
 > > 
 > > /Thomas
 > 
 > Please try to open that many tcp connections between two IPs and tell me
 > if it works!

Try it yourself.  I reckon you'll run out of file descriptors before
you hit a socket limit.  To do any more you'll have to fork() in the
server and client.

Andrew.



#include <netdb.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>

int
main (int argc, char *argv[])
{
  struct sockaddr_in sock, work;
  int wsd, sd;
  int addlen;

  int rv;

  sd = socket (AF_INET, SOCK_STREAM, 0);
  if (sd == -1)
    {
      perror ("No socket");
      exit (1);
    }
  sock.sin_family = AF_INET;
  sock.sin_port = htons (5000);
  sock.sin_addr.s_addr = INADDR_ANY;
  rv = bind (sd, (struct sockaddr *) &sock, sizeof (struct sockaddr_in));
  if (rv == -1)
    {
      perror ("Bad Bind");
      exit (1);
    }
  rv = listen (sd, 2);
  if (rv == -1)
    {
      perror ("Bad listen");
      exit (1);
    }

  int i;
  for (i = 0;; i++)
    {
      wsd = accept (sd, (struct sockaddr *) &work, &addlen);
      fprintf (stdout, "Connection %d\n", i);
    }
  while (1);
}


#include <netdb.h>
#include <netinet/in.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>

int
main (int argc, char *argv[])
{
  struct sockaddr_in sock;
  int sd;
  int addlen;

  int rv;

  while (1)
    {
      sd = socket (AF_INET, SOCK_STREAM, 0);
      if (sd == -1)
	{
	  perror ("No socket");
	  exit (1);
	}
      sock.sin_family = AF_INET;
      sock.sin_port = htons (5000);
      sock.sin_addr.s_addr = inet_addr("127.0.0.1");
      rv = connect (sd, (struct sockaddr *) &sock, 
		    sizeof (struct sockaddr_in));
      if (rv == -1)
	{
	  perror ("Bad Connect");
	  exit (1);
	}
    }
}

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux