Below is an excerpt from my client.cpp file:
//Variables previously declared
char buffer[1024];
char sendbuffer[100];
int sockfd, b;
//Opens specified file
FILE *fp = fopen(argv[3], "rb");
while( (b = fread(sendbuffer, 1, sizeof(sendbuffer), fp)) > 0 )
{
send(sockfd, sendbuffer, b, 0);
}
I am new to client-server programming, and I'm far from being extremely proficient in C++.
When I use the code above, it's successful sending the inf, but it obviously isn't going to send the data 4 bytes at a time.
If I modified the line containing send() as shown below without making other necessary changes, I'm certain that it would be incorrect.
send(sockfd, sendbuffer, 4, 0);
It's also a pain to debug because when I make a change to the code, I have to continuously simulate a client-server interaction, which takes time to set up.
What would be the most efficient way to send this text file data 4 bytes at a time?
Also, can anyone suggest a tool or method for quickly debugging client-server programs?
Let me know if more information is needed. Thanks
Aucun commentaire:
Enregistrer un commentaire