recv() function

09/01/2012 19:42 Kingrap#1
hi friends ..
I receive a packet with the function recv ();

I receive with:

recvbuf char [255];
recv (Connect, recvbuf, 255.0);

ok, no problem ..

I Know That the receive function returns -1 (unsuccessful) or n (successful) ..
n is the number of bytes received.

how i read n?

i have the packet wrong because i receive packet + ~ ~ ~ ~
~ That character replace characters in more ..

always change the packet size

attention: i receive a packet encrypted and packet decrypted size don't is packet encrypted size..
09/01/2012 20:39 .Infinite#2
Quote:
Code:
recvbuf char [255];
huh?

Code:
char recvbuf[255];
int n = 1;
while(n > 0)
{
	n = recv(Socket, recvbuf, sizeof(recvbuf), 0);
	// handle the received bytes
}
Are you looking for something like this?
09/01/2012 22:10 Kingrap#3
yes but i don't receive complete encrypted packet..
my source code:

Code:
--edit--
what is wrong?
my friend say:

you dont need the size of decryptet packet
your problem is that you dont recieve complete encrypted packet
09/02/2012 12:26 .Infinite#4
You have to put your recv() function into a loop. Else you will not be able to receive packets longer than 255 bytes.

Code:
char recvbuf[255];
int n = 1;
while(n > 0)
{
	n = recv(Socket, recvbuf, sizeof(recvbuf), 0);
	packet.append(recvbuf);
}
packet = decrypt(packet)
09/02/2012 12:49 Kingrap#5
thx i have solved :)