Skip to content

Instantly share code, notes, and snippets.

@hubplace
Created January 6, 2012 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hubplace/1571076 to your computer and use it in GitHub Desktop.
Save hubplace/1571076 to your computer and use it in GitHub Desktop.
public static String sendTCPBytes(String bytes, String[] ip) throws IOException
{
String downloaded = null;
Socket socket = new Socket(ip[2], 58889);
socket.setReceiveBufferSize(10*1024 +1024);
socket.setSendBufferSize(10*1024+1024);
socket.setTcpNoDelay(true);
DataOutputStream upload = new DataOutputStream(socket.getOutputStream());
BufferedReader download = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String caps = bytes;
System.out.println(caps);
upload.writeBytes(caps);
upload.flush();
String get;
downloaded = download.readLine();
System.out.println("[TCP]: FROM server: >>> " + downloaded); // << always missing...
socket.close();
return downloaded;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment