import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
public String sendSocketMsg(String ip, String port, String context) {
Socket s;
DataOutputStream out = null;
String result = "failure";
try {
s = new Socket(ip,Integer.parseInt(port));
out = new DataOutputStream(s.getOutputStream());
out.write(context.getBytes());
out.flush();
result = "success";
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
if (out != null){
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}