Hello everyone..

I have a problem.. The main idea of my project is a server that accept client connections and everytime someone connects it checks if the client is available for reading or for writing with select() function.
If is ready for writing then is send a buffer.. Well, this is a sample of code..

...
FD_ZERO(&master);
FD_SET(fdmax, &master);
for(; {
read_fds = master;
write_fds = master;

if(select(fdmax + 1, &read_fds, &write_fds, NULL, NULL) == -1) {
perror("select");
return -1;
}


for(i = 0; i <= fdmax; i++) { // check through all socket

if(FD_ISSET(i, &read_fds) != 0) {

bla bla bla

}

if(FD_ISSET(i, &write_fds)) { // teh client is ready for writing

printf("send bytes: %ld\n", sizeof(jobs[counter]) );
bytes = send(i, &jobs[counter], sizeof(jobs[counter]), 0);

counter++;
}


also the client source is..

while(f == 0) {

memset(&jobs, 0, sizeof(jobs));




if((bytes = recv(sockfd, &jobs, sizeof(jobs), 0)) == -1) {
printf("Error recving\n");
}

printf("here");

bla bla bla
}

the problem is that the server althougt is was supposed to send the msg only 1 time it is send it 10-15 times... it is like finds the client client all the time available for writing ( maybe i am doing sthng wrong with select and fds?).. Also the client exiting with segmentation fault JUST AFTER the printf function and i dunno why.. i suppose it is from the "oversending" of the packets from the server

What should i do ? Thanks in advance..
(i compiled it with gcc on Ubuntu distro)