Programming with Java, Swing and Squint phần 4

chúng tôi thay vì lần đầu tiên sử dụng "+" nhà điều hành để nối các văn bản của các mục trình đơn tìm kiếm chuỗi lạ đen "\ n". Để đánh giá cao mục đích của nghĩa đen "\ n", nhớ lại rằng khi chúng tôi lần đầu tiên giới thiệu các hoạt động nối trong mã ví dụ "Tôi xúc động" + numberOfClicks + "thời gian (s)" | Send a message when the button is clicked public void buttonClicked Establish a NetConnection and say hello to the server NetConnection connection new NetConnection SMTP_SERVER SMTP_PORT n HELO n Send the TO and FROM addresses MAIL FROM n RCPT TO n Send the message body DATA n . n Terminate the SMTP session QUIT n Figure The buttonClicked method of a simple SMTP client A Closing Note Just as saying Goodbye is not the same as hanging up the phone sending a QUIT command to an SMTP server is not the same as ending a TCP connection. As a result after the QUIT command is sent and the server s reply is received our program s buttonClicked method still has to invoke a method to end the TCP connection. This is done by applying the close method to the connection itself rather than to its in or out streams using a statement like With this detail we can now present the complete code for our SMTP client s buttonClicked method. This code can be found in Figure . What s Next Just as the out stream associated with a NetConnection provides both a method named println and a method named print there is a method named next that can be applied to the in stream 100 800 To carol@ From tom@ Enter your message below Carol Even though does not even exist I can still send a message to your address through my mail server. When my server realize that you don t exist it will send me a mail message warning me that it could not forward my message.

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
11    115    2    04-07-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.