i want to use the same socket address for multiple calls for this task.
i tried to get the address from different class but didn't work .
please help !!!
my call from different class is:
new ConnectToServer().execute(ip, "2000", "br1");
my code for task is:
public class ConnectToServer extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... parms) {
// TODO Auto-generated method stub
try {
Socket s = new Socket(parms[0], Integer.parseInt(parms[1]));
// ******
OutputStream os = s.getOutputStream();
BufferedOutputStream out = new BufferedOutputStream(os);
if (parms[2] == "br1") {
out.write("rr1".getBytes());
out.write('\n');
out.flush();
} else if (parms[2] == "br2") {
out.write("rr2".getBytes());
out.write('\n');
out.flush();
} else if (parms[2] == "br3") {
out.write("rr3".getBytes());
out.write('\n');
out.flush();
} else if (parms[2] == "br4") {
out.write("rr4".getBytes());
out.write('\n');
out.flush();
} else if (parms[2] == "bb1") {
out.write("bb1".getBytes());
out.write('\n');
out.flush();
} else if (parms[2] == "bb2") {
out.write("bb2".getBytes());
out.write('\n');
out.flush();
} else if (parms[2] == "bb3") {
out.write("bb3".getBytes());
out.write('\n');
out.flush();
} else if (parms[2] == "bb4") {
out.write("bb4".getBytes());
out.write('\n');
out.flush();
}
// s.shutdownOutput();
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}