tailieunhanh - java programming language basics phần 6

Ví dụ 1: Client-Side hành vi chương trình khách hàng trình bày một giao diện người dùng đơn giản và nhắc nhở cho đầu vào văn bản. Khi bạn bấm vào Click Me nút, văn bản được gửi đến chương trình máy chủ. Chương trình khách hàng mong đợi một tiếng vang từ máy chủ và in tiếng vang mà nó nhận được đầu ra tiêu chuẩn của nó. | Java TM Language Basics Part 2 Lesson 1 Socket Communications http Programming BasicJava2 from a client start a thread for that communication and continue listening for requests from other clients. About the Examples The examples for this lesson consist of two versions of the client and server program pair adapted from the application presented in Part 1 Lesson 6 File Access and Permissions. Example 1 sets up a client and server communication between one server program and one client program. The server program is not multi-threaded and cannot handle requests from more than one client. Example 2 converts the server program to a multi-threaded version so it can handle requests from more than one client. Example 1 Client-Side Behavior The client program presents a simple user interface and prompts for text input. When you click the Click Me button the text is sent to the server program. The client program expects an echo from the server and prints the echo it receives on its standard output. Example 1 Server-Side Behavior The server program presents a simple user interface and when you click the Click Me button the text received from the client is displayed. The server echoes the text it receives whether or not you click the Click Me button. Example 1 Compile and Run To run the example programs start the server program first. If you do not the client program cannot establish the socket connection. Here are the compiler and interpreter commands to compile and run the example. javac javac java Socketserver 2 of 8 21-04-2000 17 33 Java TM Language Basics Part 2 Lesson 1 Socket Communications http Programming BasicJava2 java Socketclient Example 1 Server-Side Program The server program establishes a socket connection on Port 4321 in its listenSocket method. It reads data sent to it and sends that same data back to the server

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.