100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > java socket smtp_JAVA Socket实现smtp发送邮件

java socket smtp_JAVA Socket实现smtp发送邮件

时间:2019-07-09 21:12:04

相关推荐

java socket smtp_JAVA Socket实现smtp发送邮件

MAIN函数:Socketsocket=newSocket();LogPrinter.setConnectTime(socket,"66.96.163.96",25);方法:publicstaticvoidsetConnectTime(Socketsocket,Stringname,intport){SocketAddress...

MAIN函数:

Socket socket = new Socket();

LogPrinter.setConnectTime(socket,"66.96.163.96",25);

方法:

public static void setConnectTime(Socket socket, String name, int port) {

SocketAddress address = new InetSocketAddress(name, port);

try {

long start = System.currentTimeMillis();

socket.connect(address);

System.out.println("连接成功-" + socket.getInetAddress() + " : "

+ (System.currentTimeMillis() - start) + "ms");

PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

BufferedReader input = new BufferedReader(new InputStreamReader(

System.in));

BufferedReader read = new BufferedReader(new InputStreamReader(

socket.getInputStream()));

String line = null;

String line1 = null;

while ((line = read.readLine()) != null) {

System.out.println(line);

// System.out.println(line1 = input.readLine());

out.println(input.readLine());

}

} catch (BindException e) {

System.out.println("BindException-无法绑定本地IP或端口");

} catch (UnknownHostException e) {

System.out.println("UnknownHostException-无法识别该地址或IP:" + name);

} catch (ConnectException e) {

System.out.println("ConnectException-无法连接指定端口:" + port);

} catch (SocketException e) {

System.out.println("SocketException-连接超时");

} catch (IOException e) {

System.out.println("IOException");

}

finally {

if (socket != null) {

try {

socket.close();

} catch (IOException e) {

System.out.println("关闭Socket失败");

}

}

}

根据对方发过来的提示填写信息 (完全按照书上的操作 但回执信息不同 )

应该怎么正确填写? 求正常运行的方法 只要能发出去就行

展开

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。