Hi,
i have a client which reads from the socket:
for (index=0;index<SCALERS;index++)
{
read(my_socket,vectorScalerPointer,BUFLEN);
read(my_socket,resultScalerPointer,BUFLEN);
sum+= atoi(vectorScaler)*atoi(resultScaler);
}
and a server program which writes to it.
for (index=0;index<SCALERS;index++)
{
sprintf(ascii,"%d",(*matrixStruct)._vector[0][index]);
write(fd,ascii,BUFLEN);
sprintf(ascii,"%d",(*matrixStruct)._mat[atoi(whichRow)][index]);
write(fd,ascii,BUFLEN);
}
now the problem is the programs are in a "race condition"
usualy the server writes into the buffer all the words before the client
starts reading them.
is there anyway (NOT SLEEPING) that the server writes into buffer
and then waits until someone READS from the buffer?
something like wait() or isempty(socket buffer)
?
THANK YOU.
config :
socket(PF_INET, SOCK_STREAM, 0);
bind(main_socket,(struct sockaddr *)&my_addr, sizeof(my_addr));
listen(main_socket, QUEUE_SIZE);