Networking Java Solutions Homework Get a reference to the socket’s output stream

Document Type
Homework Help
Book Title
Computer Networking: A Top-Down Approach 6th Edition
Authors
James F. Kurose, Keith W. Ross
Solutions for Mail User Agent: Simplified Version
import java.io.*;
import java.net.*;
public class EmailSender
{
public static void main(String[] args) throws Exception
{
throw new Exception("220 reply not received from server.");
}
// Get a reference to the socket's output stream.
OutputStream os = socket.getOutputStream();
// Send HELO command and get server response.
String command = "HELO x\r\n";
response = br.readLine();
System.out.println(response);
if (!response.startsWith("250")) {
throw new Exception("250 reply not received from server.");
}
// Send RCPT TO command.
}
os.write(command.getBytes("US-ASCII"));
response = br.readLine();
System.out.println(response);
if (!response.startsWith("354")) {
throw new Exception("354 reply not received from server.");
}
throw new Exception("250 reply not received from server.");
}
// Send QUIT command.
command = "QUIT\r\n";
System.out.print(command);
os.write(command.getBytes("US-ASCII"));
}
}

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.