Created
January 9, 2010 15:57
-
-
Save nazt/272960 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.*; | |
import java.net.*; | |
class TCPClient { | |
public static void main(String argv[]) throws Exception | |
{ | |
String sentence; | |
String modifiedSentence; | |
Integer i=1; | |
while(true) | |
{ | |
Socket clientSocket = new Socket("localhost", 6789); | |
DataOutputStream outToServer = | |
new DataOutputStream(clientSocket.getOutputStream()); | |
BufferedReader inFromServer = | |
new BufferedReader(new | |
InputStreamReader(clientSocket.getInputStream())); | |
outToServer.writeBytes(i.toString() + '\n'); | |
modifiedSentence = inFromServer.readLine(); | |
System.out.println("# "+ i.toString() +" -> FROM SERVER: " + modifiedSentence); | |
clientSocket.close(); | |
i++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment