tags:

views:

40

answers:

1

I'm developing a TCP Server in C language that can save data to mysql. The problem is "buf" cannot be save/insert into mysql. But "name" can be save/insert into mysql. Do u know what is the problem is? and how to fix that? I'm very glad if u can help me. below is the code.

to compile : gcc -o tcpecho $(mysql_config --cflags) tcpecho.c $(mysql_config --libs)

A: 

It looks like the data from the first call to recv is discarded without being inserted into the database. Also, you're passing the results of the later recv calls to sprintf without null-terminating them at the correct position for the number of bytes read in that call.

Jim Lewis