正在加载图片...
Establishing a connection in Java The java. net package Permits the creation of a tCP/iP connection between two applications Before a connection can be established the server must start listening to one of the ports ServerSocket serverSocket new ServerSocket(port)i Socket clientsocket serverSocket accept()i For a client to connect to a server: Socket clientsocket= new Socket(host, port)i www.oseng.com O Lethbridge/Laganiere 2001 Chap 3: Basing Development on Reusable© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 23 Establishing a connection in Java The java.net package • Permits the creation of a TCP/IP connection between two applications Before a connection can be established, the server must start listening to one of the ports: ServerSocket serverSocket = new ServerSocket(port); Socket clientSocket = serverSocket.accept(); For a client to connect to a server: Socket clientSocket= new Socket(host, port);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有