multiplexage quand tu nous tiens
Salut !
Dans le cadre de mon boulot, j'utilise les sockets et je fais du multiplexage.
Je crée mon buffer multiplexé (qui contient des entêtes et des données) et j'envoie le tout avec writev(&fd,Mux_Buffer,size) (size < IOV_MAX)
Tout va presque bien ... sauf que sur 10 exécutions 6 fois j'ai un résultat et 4 fois j'en ai un autre.
Je me demande donc si j'ai pas un pb avec la taille de la socket ...
ma question : y a-t-il une taille max de données qu'on peut écrire sur une socket ?
merci d'avance
pour info, le code en question
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| /* Création du buffer multiplexé */
pt_mess = (thePort->input->data);
memcpy( &Mux_Buffer[3*IDX], &(thePort->iPort), sizeof(thePort->iPort));
currentBufSize = currentBufSize + thePort->iPort.iov_len;
printf("Mux_Buffer[%d] = %d\n",3*IDX,Mux_Buffer[3*IDX]);
memcpy( &Mux_Buffer[3*IDX + 1], &(thePort->iTaille), sizeof(struct iovec));
currentBufSize = currentBufSize + thePort->iTaille.iov_len;
printf("Mux_Buffer[%d] = %d\n",3*IDX+1,Mux_Buffer[3*IDX+1]);
memcpy( &Mux_Buffer[3*IDX + 2], pt_mess, sizeof(struct iovec));
currentBufSize = currentBufSize + thePort->input->data->iov_len;
printf("Mux_Buffer[%d] = %d\n",3*IDX+2,Mux_Buffer[3*IDX+2]);
IDX++;
Com_Sampling_Mux_Buffer_Send(&Mux_Buffer[formerIdx],(3*IDX)-formerIdx);
code de Com_Sampling_Mux_Buffer_Send
void Com_Sampling_Mux_Buffer_Send(struct iovec * Mux_Buffer,int size)
{
struct fd_set fd;
struct timeval time_out;
long status;
int handle;
int rwrite;
if(Mux_Buffer == NULL)
return;
if(size == 0)
return;
FD_ZERO(&fd); //!< Initialize structure
FD_SET(descOutput, &fd); //!< Set structure to current socket
time_out.tv_sec = 0; //!< wait socket delay
time_out.tv_usec = 0;
status = select((descOutput + 1), NULL, &fd, NULL, &time_out);
if(status > 0)
{
printf("SizeSent = %d\n",size);
rwrite = writev(descOutput, Mux_Buffer, size);
printf("-------- rwrite = %d---------\n",rwrite);
}
else
{
perror();
}
} |