나는 안드로이드에서 채팅 응용 프로그램의 요청을 처리 할 HTTP 서버를 만들고 싶습니다. 정말 혼란 스럽기 때문에 ... 코드에서 소켓을 사용해야합니까? 클라이언트가 서버와 통신하도록하려면 어떻게해야합니까? 클라이언트에서 요청을 수락하고 응답을 받기 위해 서버에 추가해야하는 코드는 무엇입니까? 클라이언트에서 사용하는 코드는 다음과 같습니다.자바 서버 (HTTP/소켓)
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://localhost:80");
List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
nvps.add(new BasicNameValuePair("username", username1));
nvps.add(new BasicNameValuePair("password", password1));
try {
UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(nvps, HTTP.UTF_8);
httppost.setEntity(p_entity);
//Execute HTTP Post Request
HttpResponse response = client.execute(httppost);
Log.v(TAG,"something");
Log.v(TAG, response.getStatusLine().toString());
HttpEntity responseEntity = response.getEntity();
정말 답이 필요합니다. 고맙습니다!!!
답장을 보내 주셔서 감사합니다. 이제는 나에게 더 분명하게 보인다. 고맙습니다! – anna