Sending TCP data from Android (as client) - no data being sent?

前端 未结 3 1672
梦如初夏
梦如初夏 2020-12-24 15:28

I\'m trying to send data from my Android app to my PC over TCP.

The code is as follows:

Socket socket = new Socket(\"10.0.78.75\", 50505);   

Output         


        
相关标签:
3条回答
  • 2020-12-24 16:14

    Total guess this one, but have you tried calling flush() on the output stream before closing?

    0 讨论(0)
  • 2020-12-24 16:18

    Try putting an out.flush();out.close(); after the println(..);

    0 讨论(0)
  • 2020-12-24 16:18

    I had the same problem and Haphazard's solutions wasn't good enough for me. I think that you should use (in this case) output.flush(); and output.close(); instead of out.flush(); and out.close();. And you have to remember about internet permission in AndroidManifest.xml:

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    

    after <uses-sdk> and before <application>

    0 讨论(0)
提交回复
热议问题