listen소켓이 21개까지만 생성되고 그이상 접속을 받지 않네요 ㅠ

zamgyul의 이미지

다음과 같이 한개의 소켓을 생성후 listen으로 약 50개의 listen소켓을 연결하려고 하는데요.
MAX_CPU=50;
21개까지의 소켓만 연결이 되고 그이상은 연결이 안되네요.
/* i가 20까지 증가후 여기에서 멈춤. */ 의 위치에서 멈추는데 무슨문제가 있는걸까요..

즉 20개까지만 socket연결을 받고 그이상 연결요청을 해도 accept에서 멈춘채로 변화가 없어요 ㅠ

int tcpServ_m(int iLevel)
{
int i, maxfd;
struct sockaddr_in clientaddr, serveraddr;
int iSizeSockAddr = sizeof(struct sockaddr_in); /* size of socket address structure */
int server_sockfd, client_sockfd;
int iSizeMsg;
char *pcBufMsg;
struct stMsg *pstBufMsg;
int iCntBuf[MAX_CPU];
int client[MAX_CPU];
char ipStore[255][30];
int portStore[255];
int blen=65536;
int iIntId;
int iBrtN;
int iBrtN_R;
int *piBufFlag;

fd_set readfds, allfds;

iIntId = bslVmeIntToId(iLevel);
bslIntSetVect(iIntId, (void*)&vmeIsrServ, iLevel);
bslVmeIntEnable(iLevel);

semVmeIsrServ = semBCreate(SEM_Q_FIFO, SEM_EMPTY);

/* INET 소켓연결을 작성한다. */
if ((server_sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("socket"); return (ERROR); }

memset((char *)&serveraddr, 0, iSizeSockAddr);
serveraddr.sin_family = AF_INET;
serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
serveraddr.sin_port = htons(SERVER_PORT_NUM);

if (bind (server_sockfd, (struct sockaddr *)&serveraddr, iSizeSockAddr) == -1) {
perror("bind"); return (ERROR); }
if (listen(server_sockfd, 5) == -1) {
perror("listen"); return (ERROR); }
/* INET 소켓작성 끝 */

/* INET 소켓 fd 에 대하여, fd_set 에 등록한다. */
FD_ZERO(&readfds);
FD_SET(server_sockfd, &readfds);

printf("wating for connection of %d clients.\n",MAX_CPU);
for (i=0; i {
printf(" wating accept~!\n"); /* i가 20까지 증가후 여기에서 멈춤. */
client_sockfd = accept(server_sockfd, (struct sockaddr *)&clientaddr, &iSizeSockAddr);
printf(" after accept~!\n");
/* maximum size of socket-level receive buffer */
if (setsockopt (client_sockfd, SOL_SOCKET, SO_RCVBUF, (char *) &blen, sizeof (blen)) < 0) {
perror ("setsockopt SO_RCVBUF failed"); exit (1); }
if (setsockopt (client_sockfd, SOL_SOCKET, SO_SNDBUF, (char *) &blen, sizeof (blen)) < 0) {
perror ("setsockopt SO_SNDBUF failed"); exit (1); }

client[i] = client_sockfd;
strcpy(ipStore[i], inet_ntoa (clientaddr.sin_addr));
portStore[i] = ntohs (clientaddr.sin_port);

FD_SET(client_sockfd,&readfds);
maxfd = client_sockfd;
printf("i=%d : client_sockfd=%d, IP=%s, port=%d\n", i, client_sockfd, ipStore[i], portStore[i]);
}
printf("connection ok! of %d clients!\n", MAX_CPU);

}
}

zamgyul의 이미지

i는 client를 한개씩 연결할때마다 증가하고 accept에서 대기상태로 있습니다.

client에서는 connect로 연결만 합니다.

cjwgns의 이미지

일단 int listen(SOCKET s, int backlog);

에서 backlog가 5개로 설정되어 있으니 5개의 client이상은 동시접속이

불가능할 것으로 보이네요.

zamgyul의 이미지

int listen(SOCKET s, int backlog); 의 backlog를 100으로 해도 마찬가지 인데요 ㅠ

irondog의 이미지

socket은 file descriptor라고 보시면 됩니다.
시스템에서 정의된 file descriptor의 갯수가 적어서 socket을 더이상 생성 못 하는 문제가 아닐까 싶습니다만...

hhttp://www.xenoclast.org/doc/benchmark/HTTP-benchmarking-HOWTO/node7.html#SECTION00072000000000000000
여기서 "Increasing the file descriptor limit"을 참고해 보세요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.