Hi All;
I have a problem here. I have a file and i used fgets to read a line from the file and when i print it out its grand. So when i try to use this with sockets i hit a problem.
I fget into an array and then write it to the socket eg
write(sockfd, buffer 255);
So when my server receives this, and the code goes like this
Code:char buffer[256]; read(sock, buffer, 256); fputs(buffer, stdout);
I get what i sent over but alot of rubbish is printed out after it. I think its printing out my string and the remainer of the buffer. Am i right in this thinking abd how do i solve the problem and why does it occur when transporting over the socket?
Should i use strlen(buffer) instead of the size of 256?
THanks