I'm not sure on the syntax though,
I know that in client its called sockfd, and in server newsockfd.
and this is where my server executes code after a connection:
Code:
for (;;) {
/* accept a connection */
if ( (newsockfd = accept(sockfd, NULL, NULL)) == -1) {
perror("accept call failed");
continue;
}
/* spawn a child to deal with the connection */
if (fork() == 0) {
while (recv(newsockfd, buf, MAXLINE, 0) > 0) {
parse(buf, args1, args2);
execute(args1, args2);
send(newsockfd, buf, MAXLINE, 0);
}
/* when client is no longer sending information
the socket can be closed and the child process
terminated */
close(newsockfd);
exit (0);
}
Do i dup() the stdout like i would for a pipe?
close(1);
dup(p[1]);
close(p[0]);
If so what am I assigning it too to send it back to the client?