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();
}
} |
Partager