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

subject Type Homework Help
subject Pages 2
subject Words 410
subject Authors James F. Kurose, Keith W. Ross

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
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.
page-pf2
}
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.