-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoilmakerClient.java
More file actions
73 lines (61 loc) · 2.16 KB
/
Copy pathfoilmakerClient.java
File metadata and controls
73 lines (61 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import javax.swing.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.Random;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;
/**
* Created by Yufei Xu on 11/2/2016.
*/
public class foilmakerClient {}
//public static String reply;
/*
// public static String reply2;
public static String sendmessage(String inputLine) throws IOException {
Socket socket = foilmakerController.socket;
PrintWriter outToServer = null;
BufferedReader inFromServer = null;
Scanner scanner = new Scanner(System.in);
// Connect to server
//System.out.println("Enter the server port");
//serverPort = scanner.nextInt();
//socket = new Socket(serverIP, serverPort);
OutputStream os = socket.getOutputStream();
outToServer = new PrintWriter(os, true);
InputStream is = socket.getInputStream();
inFromServer = new BufferedReader(new InputStreamReader(is));
outToServer.println(inputLine);
PrintWriter outToServer = new PrintWriter(socket.getOutputStream(), true);
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(socket.getInputStream()));
outToServer.println(inputLine);
//socket.setSoTimeout(1);
//reply=inFromServer.readLine();
reply = null;
while (reply == null) {
try {
reply = inFromServer.readLine();
System.out.println(reply);
} catch (SocketTimeoutException e) {
e.printStackTrace();
}
// try {
// Thread.sleep(1);
// } catch (InterruptedException e1) {
// e1.printStackTrace();
// }
}
socket.setSoTimeout(1000);
/* if((reply=inFromServer.readLine())!=null) {
System.out.println("Recieved mesaage:" + reply);
}
return reply;
}
public static String reply(){
return reply;
}
}
*/