Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7874437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:48:21+00:00 2026-06-03T02:48:21+00:00

Im trying to send a command through telnet to my computer which then sends

  • 0

Im trying to send a command through telnet to my computer which then sends the command to a serial port, when using telnet using

adb shell
$telnet 172.20.104.203 5334
$h

it returns the data from the command h, how ever when I try to do this using android it connects to the socket, I can see this on the computer, it sends the command but then as soon as it logs that it has sent it hangs and comes up with “Application not responding” and it has wait or force close and if I wait it just stays the same.

This is my code for the telnet part

    private static final int TCP_SERVER_PORT = 5334;

    private void runTcpClient() {
        try {
            Socket s = new Socket("172.20.104.203", TCP_SERVER_PORT);
            BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
            //send output msg
            String outMsg = "$getPos"; 
            out.write(outMsg);
            out.flush();
            Log.i("TcpClient", "sent: " + outMsg);
            //accept server response
            String inMsg = in.readLine() + System.getProperty("line.separator");
            Log.i("TcpClient", "received: " + inMsg);
            //close connection
            s.close();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } 
    }

It logs the send, but it never logs the receive, I thought it might be something to do with the amount of data being received so I just sent

$getPos 

instead but it still hangs.

Any one know what could be happening?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:48:22+00:00Added an answer on June 3, 2026 at 2:48 am

    I’m not familiar with the particulars of the platform, but its unlikely that a readline will work on a socket/tcp stream, or if it works, it will work unreliably. Data coming in from a socket is not necessarily organized into ‘lines’, but instead packets of a particular size. A ‘read’ performed on a socket will return some number of bytes.

    The client doing such reads needs to read each packet, buffer them until it receives an agreed-upon ‘end of data’ marker. The marker agreed-upon is determined by protocol.

    You’ve shown us the client side of your code. Do you have a corresponding server side?

    From what you have here, my guess is that your client code is waiting patiently for an ‘end of line’ that for some reason, will never come. OR there’s something wrong at the server end and the server isn’t sending any data to the client.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access and send SMS through Wavecom's FXT-009 using Serial Port
I'm trying to send a sms via a Nokia phone over serial which is
I am trying to pass property through command line parameter ($args[0]) as follows using
I'm trying to send message using tibrvsend command. The scenarios is like below ,
I am trying to send a get or a post through a command-line argument.
I'm trying to send an HTTP command using VB.NET and I'm not quite sure
I am trying to send output of an query through mail. I am using
I am trying to send touch events using batch files (.bat) and the adb
I'm trying to send data to a web service using jQuery's post() command -
I'm trying to send a byte[] (using PUT) with Restlet but I can't find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.