title: What does the echo() function do in this program?
body: <p>This is the description of the project I'm working on:</p>
  
  <p>The
  assignment requires you to write two programs (echoClient and
  echoServer) to demonstrate communication between two processes
  using TCP socket.
  The echoServer program should take a port number (for example
  6789) as the input:</p>
  
  <pre><code>$echoServer 6789
  </code></pre>
  
  <p>The echoClient program should take the server IP address (127.0.0.1)
  and the server port as the input:</p>
  
  <pre><code>$echoClient 127.0.0.1 6789
  </code></pre>
  
  <p>The echoServer opens a socket and waits requests from the
  user specified port.
  (Make sure checking the bind result. You will very likely
  have some programs by you or others occupied the port already).
  When a connection is successfully setted up, the echoServer
  read in what data from the socket, and echo it back by writing
  "Echo: " where "input strings" are whatever
  data the echo server reads in.
  The echoClient once starts to run, it opens a socket to
  connect to the echoServer. Once it connects to the server,
  it sends a string to the server, and then reads from the
  reply from the server, and print it out.
  The echoServer program needs to be able support concurrent
  requests. The basic structure of the server is provided as
  following (you need to implement the echo function and the
  parts of main function indicated by the comments.)</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;    
  #include&lt;sys/socket.h&gt;
  #include&lt;arpa/inet.h&gt; 
  #include&lt;unistd.h&gt;  
  
  void echo (int sid, char *str);
  int main (int argc, char **argv){
    int sockid, s;
    /* take in user specified port number from commandline argument */
    /* set up socket */
    int s = socket(PF_INET, SOCK_STREAM, 0);//I added this
    while ((s=accept(sockid, ... ))&gt;0) {
      if (fork()==0){
        /* Child process */
        read(s, buf ....);
        echo(s, buf);
        exit();
      }
    }
  }
  </code></pre>
  
  <p>My question is: What is the echo() function in the above program supposed to do?  And what are the steps to implement this function?</p>