public void connect() {
AsyncTask read = new AsyncTask() {
private String[] values;
@Override
protected Void doInBackground(Void... arg0) {
try {
socket = new Socket(**ip.getText().toString(),** 12345); //这里出了问题
writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
publishProgress("@success");
} catch (IOException e) {
Toast.makeText(MainActivity.this, "Build fail!", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
try {
String line = null;
while ((line = reader.readLine()) != null) {
publishProgress(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}