im sending data from server.exe like this
for(int i=0;i<10;i++)
{
sprintf( buffer,"%d",i);
SDLNet_TCP_Send(clientSocket, buffer, strlen(buffer)+1);
}
from client.exe
if i use this:
while(1)
{
if(SDLNet_CheckSockets(socketSet,0)>0)
{
if(SDLNet_SocketReady(clientSocketTCP)>0)
{
int RecvSizeResult=SDLNet_TCP_Recv(clientSocketTCP, buffer, 5000);
cout<<"RecvSizeResult= " << RecvSizeResult <<endl;
if(RecvSizeResult>0)
{
cout<<"buffer= " <<buffer <<endl;
}
}
}
}
and i am taking this result:
RecvSizeResult = 11
buffer = 0
0 is my first message after that i cant take any other messsages
and i tried another way in client.exe like this :
while(1)
{
if(SDLNet_CheckSockets(socketSet,0)>0)
{
if(SDLNet_SocketReady(clientSocketTCP)>0)
{
while(1)
{
int RecvSizeResult=SDLNet_TCP_Recv(clientSocketTCP, buffer, 5000);
cout<<"RecvSizeResult= " << RecvSizeResult <<endl;
cout<<"buffer= " <<buffer <<endl;
if(RecvSizeResult<=1)
{
break;
}
}
}
}
}
this time i generally took same result but sometimes i am taking 2 messages but not all . like this:
RecvSizeResult = 11
buffer = 0
RecvSizeResult = 4
buffer = 7
my question is how can i take all messages? like this:
buffer=0 buffer=1 buffer=2 buffer=3 ... buffer=9