Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Max connections per socket

Posted on 2008-10-10
6
Medium Priority
?
4,329 Views
Last Modified: 2013-11-17
I'm trying to figure out how/where I can determine the maximum number of connections a socket can have. We're using IBM AIX v5.2, ML 2.
0
Comment
Question by:ddavis78725
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 22688558
Hi,
have a look at this:
http://www.experts-exchange.com/OS/Unix/AIX/Q_22056628.html

Basically it's the "somaxconn" value which is of intererest here.
With "no -o somaxconn" you will probably see
"somaxconn = 1024" which is the default value in AIX
for the maximum listen backlog.

To change, enter "no -o somaxconn=[new value]"

For further information concerning "Netwok Options"
simply consult no' s manpage ("man no")

Also, you might want to consult the AIX documentation about the listen() subroutine found in:
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.commtechref/doc/commtrf2/listen.htm

Norbert



0
 
LVL 62

Expert Comment

by:gheist
ID: 22695365
Which way that socket will have those connections?

basically when you accept() it creates new socket. thats limited by system resources then.

it is sub-optimal to have more than 200 sockets/process (like apache).
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22701073
Hi,
now that we heard about listen() and accept(), here's the complete sequence
used to create sockets and work with them.
Only some preliminaries and the subroutine calls are shown, other coding is left out.
The clue is, as gheist said, the accept() subroutine (see my comment (==>) under accept() below).
The quoted ("") comments are extracted from IBM documentation (see the link I provided in my first post).
If you wish I can give you the complete sample program I once wrote for demonstration purposes.
Norbert
/* Some preliminaries: */
 
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
 
int sockfd, newsockfd;   /* fds for socket(), accept() */
struct sockaddr_in serv_addr, cli_addr; /* sockaddr_in from <netinet/in.h> */
long clilen; /* in linux 'int'! */
char buffer[];
 
/* socket() : 
"The socket subroutine creates a socket in the specified AddressFamily and of the specified type.
The socket subroutine returns a descriptor (an integer) that can be used in later subroutines 
that operate on sockets." */
 
sockfd = socket(AF_INET, SOCK_STREAM, 0); /* Address family, type, protocol */
 
/* bind() :
"The bind subroutine assigns a Name parameter to an unnamed socket. 
Sockets created by the socket subroutine are unnamed; 
they are identified only by their address family. 
Subroutines that connect sockets either assign names or use unnamed sockets." 
struct sockaddr comes from <sys/socket.h> */
 
bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
 
/* listen() :
"The listen subroutine performs the following activities:
- Identifies the socket that receives the connections. 
- Marks the socket as accepting connections. 
- Limits the number of outstanding connection requests in the system queue." */
 
listen(sockfd, 5);                      /* 5 = Queue depth! */
 
/* accept() :
"The accept subroutine extracts the first connection on the queue of pending connections, creates a new socket with the same properties as the specified socket, and allocates a new file descriptor for that socket
The accepted socket cannot accept more connections. 
The original socket remains open and can accept more connections"
==> This is what gheist said: 
The number of accepted sockets is limited only by your program or system resources. <== */
 
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
 
/* Now do whatever you want with the accepted socket */
 
read(newsockfd, buffer, 255);
write(newsockfd, "Message xxxxxxxx", 17);
 
/* close the accepted socket */
close(newsockfd);
 
/* At the very end, close the original (listening) socket) */
close(sockfd);

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 62

Expert Comment

by:gheist
ID: 22703563
Please add some remarkable comments in your code for us to see where you need to know the limit and on what resource.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 22703826
@gheist: I suppose you're talking to ddavis78725 and not to me (woolmilkporc)?
I'm a little confused, because ddavis78725 didn't supply any code yet, and my code above is only for explaining purposes.
0
 

Author Closing Comment

by:ddavis78725
ID: 31505072
This is what I was looking for. Thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question