Hi All,
I have to receive a byte array of 1690 bytes from a Java system client.
The server is written in C.
I send 1690bytes but receive only 1460 bytes.
I want to know if the data format somewhere should be changed. Do help me.
Here is part of code:
OUTPUT:
totalbytes recieved = 1460
Please tell me how to correct this problem?
I have to receive a byte array of 1690 bytes from a Java system client.
The server is written in C.
I send 1690bytes but receive only 1460 bytes.
I want to know if the data format somewhere should be changed. Do help me.
Here is part of code:
Code:
//GLOBALS
#define RCVBUFSIZE 3000 /* Size of receive buffer */
unsigned char * publickey = NULL;
//part of code
char echoBuffer[RCVBUFSIZE]; /* Buffer for echo string */
int recvMsgSize; /* Size of received message */
char replyBuffer[32];
strcpy("hi", replyBuffer);
/* Receive message from client */
if ((recvMsgSize = recv(clntSocket, echoBuffer, RCVBUFSIZE, 0)) < 0)
DieWithError("recv() failed");
/* Send received string and receive again until end of transmission */
if (recvMsgSize > 0) /* zero indicates end of transmission */
{
echoBuffer[recvMsgSize] = '\0';
printf("Message received from Client is : %s", echoBuffer);
int indicator = 0;
if (send(clntSocket, replyBuffer, strlen(replyBuffer), 0) < 0)
printf("send() failed\n");
/* See if there is more data to receive */
if ((recvMsgSize = recv(clntSocket, echoBuffer, RCVBUFSIZE, 0)) < 0)
printf("recv() failed\n");
if (recvMsgSize > 0) {
echoBuffer[recvMsgSize] = '\0';
publickey = (unsigned char *)echoBuffer;
signed long keysize = sizeof(publickey);
printf("totalbytes recieved = %d\n", recvMsgSize);
printf("size of key = %d\n", keysize);
printf("\nSystem sends publickey : \n%s\n", publickey);
indicator = 3;
writefilepem (publickey, 3);
indicator = 0;
//memset(echoBuffer,0, RCVBUFSIZE);
}
}
}
close(clntSocket); /* Close client socket */
}
OUTPUT:
totalbytes recieved = 1460
Please tell me how to correct this problem?