Commit fcbcce6d authored by Jonathan Sudibya's avatar Jonathan Sudibya
Browse files

master commit

parent 76c0da7d
......@@ -100,7 +100,7 @@ public class ConnectionHandler implements Runnable {
JSONObject join = new JSONObject();
join.put("method", "join");
join.put("ip",InetAddress.getLocalHost().getHostAddress());
join.put("port",6789);
join.put("port",serverSocket);
sentence = join.toJSONString();
outToTracker.write(sentence.getBytes(Charset.forName("UTF-8")));
modifiedSentence = inFromTracker.readLine();
......
......@@ -49,12 +49,13 @@ public class Client implements Runnable {
String clientSentence = "";
int buf;
try {
System.out.println("Client ip "+threadName+ " :" +connectionSocket.getRemoteSocketAddress());
connectionSocket.setSoTimeout(3000);
System.out.println("Client ip " + threadName + " :" + connectionSocket.getRemoteSocketAddress());
//connectionSocket.setSoTimeout(3000);
inFromClient = new InputStreamReader(connectionSocket.getInputStream());
while ((buf=inFromClient.read()) != -1){
char c = (char)buf; //converting to char
clientSentence += Character.toString(c); //added to the sentence and convert char to String.
// count_kurawal = 0;
while ((buf = inFromClient.read()) != -1) {
char c = (char) buf;
clientSentence += Character.toString(c);
}
System.out.print(threadName + " : Received From "+connectionSocket.getInetAddress().getHostAddress()+ ": " + clientSentence);
if (!clientSentence.equals("")){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment