Created
May 14, 2019 08:01
-
-
Save jawith/d64ae1c7732add2fff2b17832cdbbeb7 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
public void run() { | |
StringBuilder sb = new StringBuilder(); | |
try { | |
Socket socket = new Socket( | |
defaultHostname, 80); | |
OutputStream out = socket.getOutputStream(); | |
for (int ival=1; ival<=100; ival++){ | |
out = socket.getOutputStream(); | |
out.write(dataText.getBytes()); | |
//Thread.sleep(500); | |
InputStream in = socket.getInputStream(); | |
byte buf[] = new byte[1024]; | |
int nbytes; | |
while ((nbytes = in.read(buf)) != -1) { | |
sb.append(new String(buf, 0, nbytes)); | |
} | |
Log.i("TextValue",sb.toString()); | |
String test = Integer.toString(ival); | |
} | |
Log.i("socket", ">> closed"); | |
socket.close(); | |
} catch(IOException e) { | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment