我的Java代码不会在文本框中显示从python服务器接收到的字符串(但是它可以将字符串发送到服务器)
一切正常,但我在应用程序上的接收端设置错误
try {
String hosty = "xxx.xxx.x.xx";
int porty = xxxxx;
s = new Socket(hosty,porty);
pw = new PrintWriter(s.getOutputStream());
pw.write(message);
pw.flush();
BufferedReader bufferedReader = null;
bufferedReader = new BufferedReader(new InputStreamReader(s.getInputStream()));
if( bufferedReader.ready() )
{
logy = bufferedReader.readLine(); //rcv as jason
}
else
{
logy = null;
}
TextView txtView=(TextView)findViewById(R.id.textView);
txtView.setText(logy);
pw.close();
s.close();
这是python服务器上的相关代码
conn.send("testlettestlet\n".encode('utf-8'))