Created
November 13, 2013 12:08
-
-
Save hydai/7448057 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
import java.io.DataInputStream; | |
import java.io.DataOutputStream; | |
import java.net.Socket; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.ListIterator; | |
class MyProgramA { | |
private int port=8000; | |
private ServerSocket server; | |
private List<ConnectionThread> connection = new ArrayList<ConnectionThread>(); | |
public MyProgramA() throws Exception | |
{ | |
server = new ServerSocket(port); | |
while (true) { | |
Socket socket = server.accept(); | |
ConnectionThread connectionThread = new ConnectionThread(socket); | |
connectionThread.start(); | |
this.connection.add(connectionThread); | |
} | |
} | |
public class ConnectionThread extends Thread { | |
private Socket socket; | |
private DataInputStream in; | |
private DataOutputStream out; | |
public ConnectionThread(Socket connectionToClient) { | |
this.socket = connectionToClient; | |
this.in = new DataInputStream(this.socket.getInputStream()); | |
this.out = new DataOutputStream(this.socket.getOutputStream()); | |
} | |
public void run() { | |
System.out.println(in.readDouble()); | |
out.writeDouble(30.00); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment