1 / 19

13. Networking

13. Networking. Java. public class SumTest { public static void main(String a1[]) { int a, b, sum; a = Integer.parseInt (a1[0]); b = Integer.parseInt (a1[1]); sum = a + b ; // 두 수를 더하는 부분입니다 System.out.println (" 두수의 합은 " + sum + " 입니다 "); } }.

ethan
Download Presentation

13. Networking

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 13. Networking Java public class SumTest { public static void main(String a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두 수를 더하는 부분입니다 System.out.println("두수의 합은 " + sum + "입니다"); } }

  2. After the server accepts the connection, communication between server and client is conducted the same as for I/O streams. The server must be running when a client starts. The server waits for a connection request from a client. To establish a server, you need to create a server socket and attach it to a port, which is where the server listens for connections. After a server socket is created, the server can use this statement to listen for connections. The client issues this statement to request a connection to a server. Client/Server Communications

  3. Data Transmission through Sockets InputStream input = socket.getInputStream(); OutputStream output = socket.getOutputStream();

  4. A Client/Server Example • Problem: Write a client to send data to a server. The server receives the data, uses it to produce a result, and then sends the result back to the client. The client displays the result on the console. In this example, the data sent from the client is the radius of a circle, and the result produced bythe server is the area of the circle.

  5. A Client/Server Example, cont.

  6. A Client/Server Example, cont.

  7. Server.java

  8. Client.java

  9. Client.java

  10. ServerSocket Class - Constructor - Method ServerSocket(int port) throws IOException) 형식

  11. Socket Class - Constructor Socket(String hostName, int port) throws UnknownHostException, IOException 형식

  12. Method

  13. TCP Socket Network Network Client Server Client Server

  14. Excercises

  15. Excercises

  16. Server Message

More Related