vendredi 27 mars 2015

Udp readfrom until the end



Socket Used : udp


I have a client who sends 5000 bytes and a server with this code :


Client code :



cod = sendto (sFd, (void *) buffer, 5000, 0, (struct sockaddr *)
&soc, sizeof (struct sockaddr_in));


Server code :



//leghtBuffer = 5000
while (lenghtBuffer > 0 )
{
//I will insert a signal if pass more than 30 s ...
cod = recvfrom (sFd, buffer,256 , 0, (struct sockaddr *) &clientSoc, &lungimeSocket);

printf("Am received %d bytes " ,cod );
lenghtBuffer = lenghtBuffer - cod;

}


How can I read more than 1 time 256 bytes from this while (still using Udp socket)?




Aucun commentaire:

Enregistrer un commentaire