Chat freely about anything...

User avatar
By kingfisher
#4424 Forgot to mention that there is another bug (which is present in the original code btw) you should read 1 byte less than the size of the buffer if you set
recv_buf[recbytes] = 0;
In case you receive 128 bytes you will write at position 129, out of bound.
Would be better
while ((recbytes = read(client_sock , recv_buf, 127)) > 0) {
User avatar
By alonewolfx2
#4437 thank you. i missed out "\n" char. some times i need a break for see :)

kingfisher wrote:Forgot to mention that there is another bug (which is present in the original code btw) you should read 1 byte less than the size of the buffer if you set
recv_buf[recbytes] = 0;
In case you receive 128 bytes you will write at position 129, out of bound.
Would be better
while ((recbytes = read(client_sock , recv_buf, 127)) > 0) {