Socket Resource temporarily unavailable

eyal.rif_at_gmail.com
Date: 09/28/05


Date: 28 Sep 2005 04:52:33 -0700

Hi,

I am the following issue -
the following program accept socket and tries to read and write to the
socket.

the "send" - has no problem but on "read" or "recv" I get the following
error - "Resource temporarily unavailable"

any idea what could be the problem?

if((sock = accept(listener,(struct sockaddr *)&sin,&namelen)) < 0) {
                if(errno == EAGAIN) return(-1);
                if(errno != EINTR) {
                        cl_error("Error %d accepting connection request
on port %d",
                                errno, listener);
                }
                return(-1);
        }
        if(send(sock,"Handling your connection - Please
wait\n",strlen("Handling your connection - Please wait\n"),0) == -1)
                perror("send");
        c = read(sock,(void *)buf,160,0);
        Set to non-blocking IO
        if( c < 0) perror("Error read on mcs_accept before Set to
non-blocking IO-");
        fcntl(sock, F_SETFL, O_NONBLOCK);
        if(send(sock,"Processing\n",strlen("Processing\n"),0) == -1)
                perror("send after Set to non-blocking IO");
        c = read(sock,(void *)buf,160,0);
        if( c < 0) perror("Error read on mcs_accept -");

Thanks,