One thing that's interesting to do is talk to some existing server. For example, you could write a program that connects to the NFS service, the FTP service, or the telnet service on an existing machine (like esus). Some of the protocols involved are complicated enough that this would take a while. But a protocol that is a lot easier to implement is the Post Office Protocol (POP). Some of you are probably familiar with POP servers; if you start a mail client from a PC and tell it that your mail is stored on esus, you have a couple of options for retrieving your mail - using the POP service or the IMAP service.
POP is a simple protocol - you can list your mail, download it, and optionally delete it from the server. The protocol is described in RFC 1725.
For this program, you need to implement a simple POP3 mail client to manage your mail file. It doesn't need to be anything fancy; if you want to beef it up a little, you can get some extra credit. The usage of the program should be
my_pop_client <host_name> [<user_name>]
% ping esus.cs.montana.edu
PING esus.cs.montana.edu (153.90.199.47): 56 data bytes
64 bytes from 153.90.199.47: icmp_seq=0 ttl=64 time=0.1 ms
The program should have a simple command line interface that provides the following functions:
Remember, you shouldn't be running the program on esus, but you can definitely connect to the POP server on esus to test this. In order to have anything interesting happen, you'll need to have some mail in your mail file on esus. If you have your mail set up to forward, you'll need to turn that off for a while - just rename the file .forward in your home directory to something else, then send some mail to your esus address.
You may have to do some experimenting here to figure out exactly what the POP server returns in its messages. Welcome to the real world.
You should include the following:
/* ============================================================== noecho.c * * Example of a program that turns off the echo on stdin to read * a password and then turns it back on. * * ======================================================================== */ #include <stdio.h> #include <stdlib.h> #include <termios.h> void main () { char name [32], pass [32]; struct termios tios; /* * Get the name with echoing */ printf ("Enter your name: "); scanf ("%s", name); printf ("The name is %s\n", name); /* * Output the prompt and then toggle echoing. */ printf ("Enter your password: "); /* * Get the terminal characteristics */ if (tcgetattr (0, &tios) < 0) { printf ("Could not get terminal attributes\n"); exit (-1); } /* * Change echo to off and reset. */ tios . c_lflag ^= ECHO; /* echo off */ tcsetattr (0, TCSAFLUSH, &tios); /* * Read the password. For you purists, read each character, echoing * an asterisk until a return is entered. */ scanf ("%s", pass); /* * Reset the property and reset the terminal line. */ tios . c_lflag ^= ECHO; /* echo on */ tcsetattr (0, TCSAFLUSH, &tios); /* * Don't do this, its just a test. */ printf ("\nThe password is %s\n", pass); }