Skip to content

Instantly share code, notes, and snippets.

@nazt
Created January 9, 2010 15:57
Show Gist options
  • Save nazt/272960 to your computer and use it in GitHub Desktop.
Save nazt/272960 to your computer and use it in GitHub Desktop.
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