I posted here at the beginning of the afternoon, but I now have a much clearer way to show what is going wrong with my program!!!!

I have a coffeepot control server (accepts multiple clients) and you can give various requests! Right, so the problem; when a client connects, a request message is sent to the server, the server processes the request and creates a response! However, when doing a propfind (one of the requests) I am getting a very strange error!!!!

It works perfectly the first time around, but then after that nothing is being sent from the server to the client, despite the fact that the server is printing the contents of the char array to the screen the line before it sends it and it is correct at the server end!!!!!

To show this; the clients useage...
Code:
NOTE: Message [user input] response [servers response]
Message: PROPFIND POT-1 HTCPCP/1.0
response: HTCPCP/1.0 200 OK
Properties for POT-1
Can store 10 cup(s) of coffee
Contains 5 cups of coffee

Message: PROPFIND POT-2 HTCPCP/1.0
response:
Message: PROPFIND POT-3 HTCPCP/1.0
response:
And the output at the server...
Code:
STARTING UP COFFEEPOT SERVER...
Retreiving machine status...
--------------------------------------------
-- NEW CLIENT (127.0.0.1) HAS CONNECTED
--------------------------------------------
PROPFIND Request sent by client (127.0.0.1)
sending: HTCPCP/1.0 200 OK
Properties for POT-1
Can store 10 cup(s) of coffee
Contains 5 cups of coffee

PROPFIND Request sent by client (127.0.0.1)
sending: HTCPCP/1.0 200 OK
Properties for POT-2
Can store 10 cup(s) of coffee
Contains 3 cups of coffee

PROPFIND Request sent by client (127.0.0.1)
sending: HTCPCP/1.0 200 OK
Properties for POT-3
Can store 10 cup(s) of coffee
Contains 8 cups of coffee
As you can see from the above example, the server is correctly processing my data, but why isn't the client getting the servers response!!!???!?!?!?! ARRGGHH, Its getting annoying now, I have tried everything i can think of, but still at the same place!!!!!!


The code the server uses to send messages for the propfind bit is:
Code:
          /* DID THE CLIENT WANT TO DO A PROPFIND? */
          else if (strcasecmp(tokens[0], "PROPFIND") == 0) {
            printf("PROPFIND Request sent by client (%s)\n", clientIP);
            /* PROPFIND SERVER */
            if (strcasecmp(tokens[1], "SERVER") == 0) {
              if (sprintf(sBuff, "%s %sServer Properties:\nCoffeepot server version: %s\nNumber of coffeepots: %d\r\n", VERSION, OK, VERSION, POTS) < 0) {
                printf("ERROR! Could not build response for client (%s)\n", clientIP);
              }
              else {
                n = write(newsockfd, sBuff, MAXBUFF);
                if (n < 0) printf("ERROR! Could not send respond to client (%s)\n", clientIP);
              }
            }
            /* PROPFIND POT-X */
            else if (strncasecmp(tokens[1], "POT-", 4) == 0) {
              /* FIND OUT THE COFFEEPOT NUMBER CLIENT WISHES TO PROPFIND */
              int potNo = tokens[1][4];
              potNo -= '0';              /* CONVER FROM CHAR TO INT */
              
              /* IS THE POT NUMBER VALID? */
              if ((potNo < 0) || (potNo > POTS)){
                printf("ERROR! Client (%s) sent an un-recognised PROPFIND request!\n", clientIP);
                /* RESPOND TO CLIENT */
                if (sprintf(sBuff, "%s %sERROR! No such coffeepot (pot-%d) exists on this server!\r\n", VERSION, SERVICE_UNAVAILABLE, potNo) < 0) {
                  printf("ERROR! Could not build response for client (%s)\n", clientIP);
	        }
                else {
                  n = write(newsockfd, sBuff, MAXBUFF);
                  if (n < 0) printf("ERROR! Could not send response to client (%s)\n", clientIP);
                }
              }
              else {
                /* RESPOND TO CLIENT WITH THE PROPERTIES OF THE REQUESTED POT! */
                if (sprintf(sBuff, "%s %sProperties for POT-%d\nCan store %d cup(s) of coffee\nContains %d cups of coffee\r\n", 
                   VERSION, OK, potNo, FULL, coffeepots[potNo - 1]) < 0) {
                  printf("ERROR! Could not build response for client (%s)\n", clientIP);
                }
                else {
                  printf("sending: %s\n", sBuff);
                  n = write(newsockfd, sBuff, MAXBUFF);
                  if (n < 0) printf("ERROR! Could not send response to client (%s)\n", clientIP);
                }
	      }
              n = write(newsockfd, sBuff, MAXBUFF);
              if (n < 0) printf("ERROR! Could not send response to client (%s)\n", clientIP);
            }
            /* BAD PROPFIND REQUEST */
            else {
              printf("ERROR! Client (%s) sent an un-recognised PROPFIND request!\n", clientIP);
              /* RESPOND TO CLIENT */
              if (sprintf(sBuff, "%s %sERROR! Un-Recognised PROPFIND request!\r\n", VERSION, BAD_REQUEST) < 0) {
                printf("ERROR! Could not build response for client (%s)\n", clientIP);
	      }
              else {
                n = write(newsockfd, sBuff, MAXBUFF);
                if (n < 0) printf("ERROR! Could not send response to client (%s)\n", clientIP);
              }
            }
          }
Many thanks to anybody that has a look at this!!! and thanks for your help everyone!!!!!!!!!!!!
[/code]