public static void main (String[] args) {
+ //FIXME: Implement the args parsing to set this tree values dynamically
final int BUFFER_SIZE = 1;
final int PROD_NUMBER = 20;
final int CONS_NUMBER = 20;
public class Main {
+ /**
+ * Main for testing ClientSimplifie
+ */
private static void main1() {
SocketClient client = new SocketClient();
try {
- client.sendMsg("Line 1 Line 2");
+ client.sendMsg("Line1");
String msg = client.receiveMsg();
System.out.println(msg);
}
public static void main (String[] args) {
+ SocketClient client = new SocketClient();
- try {
- SocketClient client = new SocketClient();
+ // try {
ThreadClientSend thCS = new ThreadClientSend(client);
- thCS.setMsg("Line1 Line2");
+ //FIXME: Implement a loop based on user input to set dynamically the message to sent.
+ //for (int i = 0; i < 10; i++) {
+ // thCS.setMsg("Line" + i);
+ //}
+ thCS.setMsg("Line1");
Thread thS = new Thread(thCS);
Thread thR = new Thread(new ThreadClientReceive(client));
thS.setName("thS");
thS.start();
thR.setName("thR");
thR.start();
- }
- catch (Exception e) {
- System.err.println("Exception: " + e);
- }
- finally {
- client.closeRWIO();
- }
+ // }
+ // catch (Exception e) {
+ // System.err.println("Exception: " + e);
+ // }
+ // finally {
+ // client.closeRWIO();
+ // }
}
* @param msg a string containing the message to send
*/
public synchronized void sendMsg(String msg) {
+ //NOTE: it's not really required with one socket writer thread.
while (msg.isEmpty()) {
try {
wait();
}
/**
- * [setMsg description]
- * @param m [description]
+ * Message to sent setter
+ * @param m the text message to sent
*/
public void setMsg(String m) {
msg = m;
catch (Exception e) {
System.err.println("Exception: " + e);
}
- //finally {
- // client.closeRWIO();
- //}
}
}
}