Hello,
i am trying to send a chunk of data via TCP/IP from a linux client to my C6474 evaluation board using NDK 2 and SYS/BIOS 6. I use connection-oriented sockets. The server sets up a socket and listens, the client connects. Everything fine up to this point.
The client code looks like this
#define BIG_CHUNK_SIZE 6400
#define SMALL_CHUNK_SIZE 640
char *buffer = (char*) malloc(BUF_SIZE*sizeof(char)); // BUF_SIZE = 8192
memset(buffer, 0, BUF_SIZE*sizeof(char));
int numByteSent = 0;
int result;
fprintf(stdout, "Trying to send %d byte\n", BIG_CHUNK_SIZE); fflush(stdout);
while (numByteSent < BIG_CHUNK_SIZE) {
result = send(socketDesc, (void*) &buffer[numByteSent], SMALL_CHUNK_SIZE, 0);
if (result < 0) {
perror("send()");
} else {
fprintf(stdout, "Sent %d byte\n", result); fflush(stdout);
numByteSent += result;
}
}
fprintf(stdout, "Done\n"); fflush(stdout);
The server side like this
#define BIG_CHUNK_SIZE 6400
#define SMALL_CHUNK_SIZE 640
printf("Trying to receive %d Byte\n", BIG_CHUNK_SIZE);
while (numByteRcvd < BIG_CHUNK_SIZE) {
result = recv(socketDescPeer, (void*) &buffer[numByteRcvd], SMALL_CHUNK_SIZE, 0);
if (result < 0) {
printf("recv(): Error %d\n", fdError());
} else {
printf("Received %d byte\n", result);
numByteRcvd += result;
}
}
printf("done\n");
The client sends 10 messages of 640 bytes each as expected. The server successfully receives the first message, also 640 Bytes, then calls recv() again which in turn blocks. I tried smaller amounts of data and chunk sizes. Interestingly, for 64 Byte chunks, the server successfully receives the first few (10 or so) chunks. For small amounts of data the transmission works however. Thanks for any help.
Best regards