Socket listen when using Single Client

78 views Asked by At

I wrote a server code to run on my embedded platform...it listens to wifi clients and I have made provision to accept only one client connection at a time.

so I do,

        sfd = socket(AF_INET, SOCK_STREAM, 0);
        ret=bind(sfd,(struct sockaddr*)&serv_addr,sizeof(serv_addr));
        ret = listen(sfd,5);
        while(1)
        {
            new_fd = accept(sfd,(struct sockaddr*)&client_addr,&len);
            ....
            close(new_fd);
        }

So in this case what I observe that only one client can send data...which is expected But, Another client can connect to the socket simultaneouly...although the data from 2nd client is not processed.

So is this because of the listen(5) backlog parameter. So that I can simultaneously connect to 5 connections although I may not process them.

Please help me clarify.

0

There are 0 answers