kathyayini
Programmer
I have written a program which will accept only 20 connections to the server port. If connection goes beyond 20 then below mentioned code will be executed which is in while loop
memset(cSendBuf,' ',23);
memset(&sd, '\0', 23);
printf("\nRejecting Excess Client %s ...\n",inet_ntoa(sockAddr.sin_addr));
strcpy(sd.cstrmsg,"Rejecting Excess Client"
strcpy(cSendBuf,""
printf("sd.cstrmsg is ;%s\n",sd.cstrmsg);
memcpy(cSendBuf,sd.cstrmsg,23);
int x=send(sock_id,cSendBuf,23,MSG_NOSIGNAL);
printf("x is %d\n",x);
close(sock_id);
continue;
Problem is socket closes before data is sent to client, so client fails to receive data. Is there is any way to send data first and then close the socket.
Waiting for the reply.
memset(cSendBuf,' ',23);
memset(&sd, '\0', 23);
printf("\nRejecting Excess Client %s ...\n",inet_ntoa(sockAddr.sin_addr));
strcpy(sd.cstrmsg,"Rejecting Excess Client"
strcpy(cSendBuf,""
printf("sd.cstrmsg is ;%s\n",sd.cstrmsg);
memcpy(cSendBuf,sd.cstrmsg,23);
int x=send(sock_id,cSendBuf,23,MSG_NOSIGNAL);
printf("x is %d\n",x);
close(sock_id);
continue;
Problem is socket closes before data is sent to client, so client fails to receive data. Is there is any way to send data first and then close the socket.
Waiting for the reply.