发送TCP数据的Andr​​oid(如客户端) - 发送任何数据?数据、客户端、TCP、oid

2023-09-05 07:29:55 作者:我爱的人不是我爱人`

我想从我的Andr​​oid应用程序将数据发送到我的电脑通过TCP。

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

在code是如下:

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

OutputStream out = socket.getOutputStream();       
PrintWriter output = new PrintWriter(out);         

mStatusText.setText("Sending Data to PC");         
output.println("Hello from Android");              
mStatusText.setText("Data sent to PC");            

socket.close();                                    
mStatusText.setText("Socket closed");              

我没有得到任何错误可言,而这样做,但是,服务器应用程序(C#编写的),没有得到任何数据。 它把客户端连接到它,并看到正在发送数据,但是数据串出来的空...而上为什么会这样的想法?

I don't get any errors at all while doing this, however, the server application (written in C#) does not get any data. It sees the client connect to it, and sees that data is being sent, however, the data string comes out empty... And thoughts on why this is happening?

PS:服务器code从以下站点复制并已经过测试,与C#TCP客户端。 http://www.switchonthe$c$c.com/tutorials/csharp-tutorial-simple-threaded-tcp-server

PS: The server code is copied from the following site and has been tested with a C# TCP client. http://www.switchonthecode.com/tutorials/csharp-tutorial-simple-threaded-tcp-server

推荐答案

尝试把一个了out.flush(); out.close();在的println(..);

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

 
精彩推荐
图片推荐