问题描述
|
我正在使用Android客户端连接到Python服务器。这是我的Android客户端代码,该代码通过移动Samsung迷你星系通过使用相同无线IP地址的Open套接字连接到服务器:
public void appendText(View view){
Text.append( \"\\n In chat \");
try{
// while (true)
//{
sentence=inputfld.getText().toString();
String sentence1=(\"hohohoh\");
Text.append( \"\\n DataStream creating\");
outToServer.writeBytes(sentence);
outToServer.writeBytes(sentence1);
modifiedSentence = inFromServer.readLine();
Text.append(modifiedSentence);
inputfld.setText(null);
}
}
catch(Exception modifiedsentence){
Text.append(\"Exception\");
}
}
public void connect(View view){
try {
String cmd=(\"My current location is: \" );
clientSocket= new Socket(\"192.168.1.2\",54628);
Text.append( \"\\n created a socket\");
outToServer = new DataOutputStream(clientSocket.getoutputStream());
Text.append( \"\\n created a datastream\");
inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
Text.append( \"\\n created a bufferReader\");
Text.append( \"\\n created a socket\");
} catch (SocketException e) {
e.printstacktrace();
}
catch(Exception e){
System.out.println(\"Error\");
}
}
现在的问题是我可以连接,并且我有按钮可以发送附加文本的操作事件,但是并不能让我使用手机发送。我的代码有什么问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)