Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Thread tt = new Thread()
- {
- @Override
- public void run()
- {
- sock = new Socket();
- InetAddress add = null;
- try {
- add = InetAddress.getByName("1.2.3.4");
- } catch (UnknownHostException e) {
- e.printStackTrace();
- }
- InetSocketAddress j = null;
- j = new InetSocketAddress(add, 5555);
- try {
- sock.setKeepAlive(true);
- sock.setReuseAddress(true);
- sock.setTcpNoDelay(true);
- sock.connect(j, 5000);
- } catch (IOException e) {
- e.printStackTrace();
- }
- InputStream iS = null;
- try {
- iS = sock.getInputStream();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- int res = iS.read();
- Log.e("THIS", "Read bytes = " + res);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- };
- tt.start();
Advertisement
Add Comment
Please, Sign In to add comment