R
Raza Muzaffar
I am trying to connect to an https URL address of the form:
"ip_address/file_path/file_name" using URL object and Socket objects. I have
tried creating URL objects from this available data but none of the URL
constructors take IP address. I have tried using the IP address in the place
of "host" parameter but I keep getting "java.net.UnknownHostException".
Similarly when I created socket:
SocketFactory.getDefault().createSocket("IP_address/file_path/file_name",por
t) I once again get the "java.net.UnknownHostException".
Also when I enter just the IP address without any file path or path name, I
get an error message saying the IP address should be entered in the form <IP
address>
i.e within angle brackets. The hostname/domain name is not published by the
vendor.
Can someone please point me in the right direction as to what I might be
missing.
Thanks in advance.
Regards,
Raza
Below is the sample of code I am working on:
// Get a socket factory
//SocketFactory factory = SSLSocketFactory.getDefault();
// Get a socket from factory
/*Socket socket =
factory.createSocket("65.216.120.46/secure/Pxapi.asp",HTTPS_PORT);
writer = new BufferedWriter(new
OutputStreamWriter(socket.getOutputStream()));
reader = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
writer.write(login);
writer.flush(); */
//adstar = new URL("https://secure.authorize.net/gateway/transact.dll");
this works
adstar = new URL(https://65.216.120.46/secure/Pxapi.asp);
urlConnection = adstar.openConnection();
urlConnection.setDoOutput(true);
out = new PrintWriter(urlConnection.getOutputStream());
//out.println(login);
reader = new BufferedReader(new
InputStreamReader(urlConnection.getInputStream()));
//}
String line = null;
StringBuffer sb = new StringBuffer();
while((line = reader.readLine()) != null) {
sb.append(line);
}
//writer.close();
reader.close();
System.out.println(sb.toString());
//out.println(command);
"ip_address/file_path/file_name" using URL object and Socket objects. I have
tried creating URL objects from this available data but none of the URL
constructors take IP address. I have tried using the IP address in the place
of "host" parameter but I keep getting "java.net.UnknownHostException".
Similarly when I created socket:
SocketFactory.getDefault().createSocket("IP_address/file_path/file_name",por
t) I once again get the "java.net.UnknownHostException".
Also when I enter just the IP address without any file path or path name, I
get an error message saying the IP address should be entered in the form <IP
address>
i.e within angle brackets. The hostname/domain name is not published by the
vendor.
Can someone please point me in the right direction as to what I might be
missing.
Thanks in advance.
Regards,
Raza
Below is the sample of code I am working on:
// Get a socket factory
//SocketFactory factory = SSLSocketFactory.getDefault();
// Get a socket from factory
/*Socket socket =
factory.createSocket("65.216.120.46/secure/Pxapi.asp",HTTPS_PORT);
writer = new BufferedWriter(new
OutputStreamWriter(socket.getOutputStream()));
reader = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
writer.write(login);
writer.flush(); */
//adstar = new URL("https://secure.authorize.net/gateway/transact.dll");
this works
adstar = new URL(https://65.216.120.46/secure/Pxapi.asp);
urlConnection = adstar.openConnection();
urlConnection.setDoOutput(true);
out = new PrintWriter(urlConnection.getOutputStream());
//out.println(login);
reader = new BufferedReader(new
InputStreamReader(urlConnection.getInputStream()));
//}
String line = null;
StringBuffer sb = new StringBuffer();
while((line = reader.readLine()) != null) {
sb.append(line);
}
//writer.close();
reader.close();
System.out.println(sb.toString());
//out.println(command);