서버컴퓨터 원격접속해서 확인해보니 톰캣과 9080포트는 이상없이 돌아가고 있습니다.
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
package kr.co.sysdyne.app.emf.request;
import java.io.IOException;
import java.io.InputStream;
import kr.co.sysdyne.app.emf.internal.SysdyneConstant;
import kr.co.sysdyne.app.emf.util.Utils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.json.JSONObject;
import android.content.Context;
import android.os.AsyncTask;
import android.text.TextUtils;
public class SysdyneTask extends AsyncTask<String, Void, JSONObject> implements SysdyneConstant{
private Context mContext;
public SysdyneTask(Context context) {
super();
mContext = context;
}
@Override
protected JSONObject doInBackground(String... params) {
if (mContext != null && !Utils.isNetworkAvailable(mContext)) {
return null;
}
String api = "http://" + CONST_SERVER_ADDRESS + ":" + CONST_SERVER_PORT
+ params[0];
if (TextUtils.isEmpty(api)) {
return null;
}
JSONObject result = null;
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet(api);
HttpParams httpParameters = new BasicHttpParams();
int timeoutConnection = HTTP_TIMEOUT;
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
int timeoutSocket = HTTP_SOCKET_TIMEOUT;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
try {
HttpResponse response = httpClient.execute(httpGet, localContext);
HttpEntity entity = response.getEntity();
String text = getASCIIContentFromEntity(entity);
result = new JSONObject(text);
} catch (Exception e) {
return null;
}
return result;
}
@Override
protected void onPostExecute(JSONObject result) {
super.onPostExecute(result);
if (mOnPostExecuteListener != null) {
mOnPostExecuteListener.onPostExecute(result);
}
}
private OnPostExecuteListener mOnPostExecuteListener;
public interface OnPostExecuteListener<Result> {
void onPostExecute(Result result);
}
public void setOnPostExecuteListener(OnPostExecuteListener<JSONObject> listener) {
mOnPostExecuteListener = listener;
}
protected String getASCIIContentFromEntity(HttpEntity entity) throws IllegalStateException, IOException {
InputStream in = entity.getContent();
StringBuffer out = new StringBuffer();
int n = 1;
while (n > 0) {
byte[] b = new byte[4096];
n = in.read(b);
if (n > 0)
out.append(new String(b, 0, n));
}
return out.toString();
}
}