diff options
author | dor <dor1_b@walla.com> | 2013-09-28 16:24:52 +0300 |
---|---|---|
committer | dor <dor1_b@walla.com> | 2013-09-28 16:24:52 +0300 |
commit | cc2a8b879fd189aeb9caf907838d514e3633a1af (patch) | |
tree | 0b97e52b937f6c05781ce0d2959569388d7344fc /src/ChatClient.java | |
parent | 2c5bc88072d964fb68bead02d011766696b5ee93 (diff) |
Server \client loop \ One time port
Diffstat (limited to 'src/ChatClient.java')
-rw-r--r-- | src/ChatClient.java | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/ChatClient.java b/src/ChatClient.java index 620622a..ea0eeb9 100644 --- a/src/ChatClient.java +++ b/src/ChatClient.java @@ -9,46 +9,30 @@ public class ChatClient public static void main(String[] args) throws IOException
{
String phrase;
- System.out.println("Enter you phrase");
- phrase = reader.nextLine();
int port = ChatServer.portNum;
String host = null;
Socket Soc;
OutputStreamWriter outTemp;
- try
- {
- Soc = new Socket(host, port);
- } catch (IOException e)
- {
- System.err.println("Error connecting to host " + host + ", port " + port + ": " + e);
- return;
- }
- try
- {
- outTemp = new OutputStreamWriter(Soc.getOutputStream());
- } catch (IOException e)
- {
- System.err.println("getOutputStream failed (should not have happened): " + e);
- Soc.close();
- return;
- }
+
+ Soc = new Socket(host, port);
+ outTemp = new OutputStreamWriter(Soc.getOutputStream());
BufferedWriter output = new BufferedWriter(outTemp);
InputStreamReader inputTemp = new InputStreamReader(Soc.getInputStream());
BufferedReader input = new BufferedReader(inputTemp);
while (true)
{
-
-
+ System.out.print("Write here:> ");
+ phrase = reader.nextLine();
output.write(phrase, 0, phrase.length());
output.newLine();
output.flush();
phrase = input.readLine(); // FIXME: more then 1 line
phrase = "[" + phrase + "]";
System.out.println(phrase);
-
+
}
-
- Soc.close();
+
+ //Soc.close();
}
}
|