I have to write an android client, in which i should use HttpComponents to connect to a specific Server on Port 8080. For now, all i've found, was the Examplecode from the Apache-site, which is nearly perfect for what i need, except the Port it connects to:
if (isSet)
{
throw new IOException("Hostname or Port are not set!");
}
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(serverURL + ":" + serverPort + "/maps");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null)
{
InputStream instream = entity.getContent();
int l;
byte[] tmp = new byte[2048];
while ((l = instream.read(tmp)) != -1)
{
}
}
Is there any way to change the Port? Any help would be appreciated.
I know a little about HttpComponents, but I find an example code from Apache-site, which may help you. You can try to modify the code like below for your problem.