i have a client which reads from the socket:

for (index=0;index<SCALERS;index++)
		sum+= atoi(vectorScaler)*atoi(resultScaler);

and a server program which writes to it.

for (index=0;index<SCALERS;index++)


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)

config :

socket(PF_INET, SOCK_STREAM, 0);
bind(main_socket,(struct sockaddr *)&my_addr, sizeof(my_addr));
listen(main_socket, QUEUE_SIZE);

Well, I don't know what BUFLEN is but if you set your reads and writes to a specific size (i.e. sizeof(data_type) ) then you don't need to worry about how much is written and when since the SOCK_STREAM guarantees proper order and the sizes are fixed.
If you can not reliably guarantee that each side will see sizeof (data_type) as the same size you can place headers on your data to indicate how much to read. For instance:

Send: [4,X] // where sizeof(X) == 4
   read 1 byte: => 4 // indicates the remainder of the buffer
   read 4 bytes: => X

In both of these cases it is not necessary to convert the number to text before sending and the reverse the process on the receive side. Just send the number using the methods above as a means to ensure reading the proper amount of data on the remote side.

thank you. finaly i used ctl function to check whenever the socket is empty
and only than continue. probably not the best solution but it works

This question has already been answered. Start a new discussion instead.