Created
November 13, 2013 12:09
-
-
Save hydai/7448064 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyProgramA { | |
private int port=8000; | |
private DataInputStream in; | |
private DataOutputStream out; | |
private ServerSocket server; | |
private Socket socket; | |
public MyProgramA() throws Exception | |
{ | |
server = new ServerSocket(port); | |
// 在 port 建立一個 ServerSocket | |
socket = server.accept(); | |
// 等待一個 client 的連線 | |
in = new DataInputStream(socket.getInputStream()); | |
// 建立一個 DataInputStream 來得到 client 的輸入 | |
out = new DataOutputStream(socket.getOutputStream()); | |
// 建立一個 DataOutputStream 以傳送資料給 client | |
System.out.println(in.readDouble()); | |
// 在本地的 console 印出 client 傳送過來的 double value | |
out.writeDouble(30.00); | |
// 傳送 double value 30.00 給 client | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment