Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

unable to download object through socket

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 7113
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic