Forums Register Login
unable to download object through socket
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("", 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(
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);

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

When i run my code i am getting following error :

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
This doesn't appear to be a Java problem, but a problem with your network or proxy. What happens when you type 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.
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.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 1050 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 20, 2018 15:07:26.