You can get a full-page document view by clicking on this entry title. Do not hesitate contacting me if you find an error on any of the provided answers.
Solved 1st Term2011
Solved 1st Term2011
This is a one-year compulsory Computer Networks (5662) course for Computer Engineers at the Universidad Politécnica de Valencia.
Instructor:
Dr. Miguel Sánchez





For testing purposes let's assume both users will use telnet application to have an interactive chat session (only two users per chat). Your meeting server will enable conversations between pairs of clients, but at any given moment several independent chat sessions may take place.
You can click on the title to get a copy of the assignment document.
I've been granted an Excellence in Teaching award from the local government. Among other things lecturing in English (or other foreign languages) and having high-marks on student surveys of teaching were topics assessed.
Please note that some of you are doing assumptions for assignment#1 that do not match the protocol specification. I want to bring your attention to page 4 of RFC 821 where MAIL FROM and RCPT TO commands syntax is shown. Please note there is not a space between the colon and mailbox name. Do not confuse that with what appears inside the message header (From: and To: headers, where a space is found).PrintWriter out = new PrintWriter(new FileOutputStream("received.txt"));

java SmtpServer


| 0 | T | 12 | N |
| 1 | R | 13 | J |
| 2 | W | 14 | Z |
| 3 | A | 15 | S |
| 4 | G | 16 | Q |
| 5 | M | 17 | V |
| 6 | Y | 18 | H |
| 7 | F | 19 | L |
| 8 | P | 20 | C |
| 9 | D | 21 | K |
| 10 | X | 22 | E |
| 11 | B |
$ java P2P 7123 ./ 158.42.53.17:7777
| | |
port | |
folder |
initial peer
Please note the output above shows the expected behaviour where you have three sections. On the top it is the peer list, after connect ok message that tells you the three server ports are open (p, p+1 and p+2). Next you have the list of filenames (only if your code reacts this way to an empty line query, something mine does) and in the third place you have the first 10 data bytes of the filename that appears last on your file list (FileServer.class).
$ java P2Tester 7777
>>> CONNECT OK
158.42.53.17:7777
158.42.53.17:8899
1.1.1.1:1234
P2P.class
QueryServer.class
ListManagement.class
Peers.class
FileServer.class
>>> READ FROM FILE (first ten bytes): FileServer.class
ca fe ba be 00 00 00 32 00 72




import java.net.Socket;
import java.io.*;
import java.util.Scanner;
class TestTCP {
public static void main(String args[]) throws java.net.UnknownHostException, java.io.IOException , java.lang.InterruptedException{
Socket s = new Socket ( "www.upv.es", 80 );
// Thread.sleep(100000);
PrintWriter output = new PrintWriter( s.getOutputStream(), true);
output.println("GET / HTTP/1.0");
output.println("");
Scanner input = new Scanner( s.getInputStream());
while(true) System.out.println(input.nextLine());
}
}
import java.net.*;
import java.io.*;
import java.util.Scanner;
class Server {
public static void main(String args[]) throws IOException, InterruptedException{
ServerSocket ss = new ServerSocket(8080);
while(true) {
Socket s = ss.accept();
Scanner input = new Scanner( s.getInputStream());
PrintWriter output = new PrintWriter( s.getOutputStream(), true);
System.out.println(input.nextLine()); // reads a line from the socket (client)
output.println("Hello client!");
s.close();
}
}
}