Click to See Complete Forum and Search --> : c tcp socket question


cybercrypt
02-07-2003, 12:03 PM
I am using the following line of code to read text back from my server through tcp in a connection oriented state. The problem is that the client can send as many times as it wants and the server picks up each text string sent just fine.

However if I try to send text back to teh client it only seems to work once.

ie: I get both strings sent, but they are received on the client through a single recv line which appends the first string to the second until the buffer fills up where it then feeds over to my next variable specified in the second recv line.

What do I need to do to get the client to recv 1 line from server, then recv the second line?

Thanks,

CyberCrypt

Stuka
02-07-2003, 01:26 PM
Could you post the code you're using?

cybercrypt
02-07-2003, 01:42 PM
If linux would let me copy and past I would love too.

Here is an overview:

server:
I assume you know how I'm connecting to the socket so I'll just show the send and recv lines for each side:

recv(temp_sock_descriptor, buf, 150, 0);
send(temp_sock_descriptor, buf, strlen(buf), 0);


client side:

send(socket_descriptor, str, strlen(str), 0);
recv (socket_descriptor, buf, 150, 0);

I have noticed that the null character is being stripped off of the string when it goes across which explains why, if I send to things across to the client from the server its just appending one to the other in a single recv line because the client doesn't know when its finished sending data.

If I could figure out how to get the server to and client to stop stripping the null char off I think it might work...

Thanks,

cybercrypt
02-07-2003, 02:00 PM
While sending you my code I realized that I was sending the sizeof() function which only reports the length of the char and was itself stripping the null off...

Thanks anyway but it seems to be working now.

JockVSJock
02-08-2003, 10:14 AM
Do you have Sendmail running?

You can do the following to send the code to an like a yahoo or hotmail account, I do this all of the time.



mail yourname@youremailaddress.com<foo.c++



And then you can copy and paste to this site.