Additional hints and cautions for assignment 3: * make sure you understand that the side that becomes server first sends the user name it wants to communicate with (not its own username!) the client, after receiving this name, sends back the username it wants to communicate with. If the names do not match on either side, terminate connection. the server should then go back and wait for another connection. if names match, the server will initiate the communication by sending out the first message, which you get from stdin (the keyboard). * if your program crashes or breaks out abnormally, you will find it impossible to use the same port for connections for a while. To help alleviate this, do the following: int x = 1; // 1 = option on, 0 = off setsockopt(sfd,SOL_SOCKET,SO_REUSEADDR,&x,sizeof(int)); where sfd is the file descriptor for your SERVER socket. I'll explain what this is in more detail later. * be careful while using fscanf and fprintf over the socket. Look at the man pages for fscanf to understand fully how it works. Be aware that if you try to scan a string, as in scanf("%s",buffer); it will scan characters until it sees a while space (space, tab or newline character). Now, if you use fscanf to scan a 0-terminated string over a socket, it may block. To solve this situation, make sure when you send the string you include an extra white space char in the output, like in: fprintf(sockstream,"%s ",buffer); * In general, be aware of the difference between a 0-terminated string and a string terminated by the newline char '\n'. When you write a function to read a line from the keyboard, you want to stop when you see the '\n' char, but you should also 0-terminate this string! Otherwise, when you print the buffer that it scanned into, it will continue printing past the '\n'. * Here is a sample session of my solution to the program, on both client and server. My program takes the target host ip and the target user as command-line arguments, as should yours. ">>" indicates local keyboard input, and "<<" indicates what's received from the other side. (from 147.4.150.248 - office solaris machine) > ./schat 24.44.52.64 root Connection Established! >> how are you? << I'm fine >> that's nice << ok >> .signoff. (from 24.44.52.64 - home linux machine) # ./schat 147.4.150.248 cscccl Connection Established! << how are you? >> I'm fine << that's nice >> ok << .signoff. You should be reading chapters 4 and 5 in the book at this point. I will go over forking again next week. Check webpage frequently for updates. As of now, however, all due dates stand. ** I may update this file later with additional comments **