Meanwhile, On The Server (Cont.)
/* enter an accept-write-close infinite loop */
while (1) {
/* the accept() system call will wait for a */
/* connection, and when one is established, a */
/* new socket will be created to form it, and */
/* the csa variable will hold the address */
/* of the Client that just connected to us. */
/* the old socket, s, will still be available */
/* for future accept() calls. */
cs = accept(s, (struct sockaddr *)&csa, &size_csa);
/* check for errors. if any - accept mode again */
if (cs < 0)
continue;
/* ok, we got a new connection. do the job... */
write(cs, DAYTIME, sizeof(DAYTIME));
/* now close the connection */
close(cs);
}