• Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to download object through socket  RSS feed

 
emanuel smith
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
I am trying to download object thorugh sockets in java . My code is

String servername = "http://ea-cdn.voxmedia.com"; //(String) innObj.get("value");
String filename = "http://ea-cdn.voxmedia.com/production/vox-40-maps/stylesheets/styles-358f0375.css"; //(String) request.get("url");
Socket socket = new Socket("http://10.10.78.62", 3128);
DataOutputStream bw = new DataOutputStream(
new DataOutputStream(socket.getOutputStream()));
bw.writeBytes("GET " + filename + " HTTP/1.1\n");
bw.writeBytes("Host: " + servername + ":80\n\n");

DataInputStream in = new DataInputStream(
socket.getInputStream());
String[] parts = filename.split("/");
OutputStream dos = new FileOutputStream("/home/networksassgn/" + servername + "/" + parts[parts.length-1]);
int count;
byte[] buffer = new byte[2048];
while ((count = in.read(buffer)) != -1) {
dos.write(buffer, 0, count);
dos.flush();
}
dos.close();


where Proxy_IP: 10.10.78.62 Proxy_port: 3128 since i am trying to download through our proxy server

When i run my code i am getting following error :

java.net.UnknownHostException: http://10.10.78.62
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at Downloader.main(Downloader.java:41)



Please help
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't appear to be a Java problem, but a problem with your network or proxy. What happens when you type http://10.10.78.62:3128 into a browser?

A couple of other things that will help people responding to your post: Use Code Tags, and as much as possible, post working code. For instance, you have code outside of a method. That won't compile.
 
Renee Ritchey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may be facing this problem due to your server and not the Java issues. I was facing similar issues some time back but then I contacted my service provider at http://voicearray.com/ and they provided me with the solution.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!