LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2011, 03:59 AM   #1
appilu
Member
 
Registered: Jan 2011
Distribution: RedHat,Debian-Ubuntu,Fedora
Posts: 73

Rep: Reputation: 8
Smile java.net.SocketException: Malformed reply from SOCKS server


Hi,

am getting an error "java.net.SocketException: Malformed reply from SOCKS server"

when trying to create a socket to an ip.but when i use localhost,its working fine
Error
---------
Socket skt=new Socket("192.168.1.18",4000);

working
-------

Socket skt=new Socket("localhost",4000);

can u help me
 
Old 06-22-2011, 06:00 AM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
I cannot see anything wrong with the code you have presented. Constructing a Socket object is typically done by the client. A server should construct a ServerSocket object.

I tested the code below, and received the expected exception that the client could not connect. I would suspect that the exception thrown by your code is due to something else (a major clue is that the Socket constructor will not throw a SocketException!). Please create a simple example to test your theories about sockets, and report back here if you still have trouble.

Very simple client code:
Code:
import java.net.Socket;
import java.net.UnknownHostException;
import java.io.IOException;

class Client
{
   public static void main(String[] arggs)
   {
      try {
         Socket sock = new Socket("192.168.1.10", 4000);

         // ...
      }
      catch (UnknownHostException e) {
         System.err.println(e.toString());
      }
      catch (IOException e) {
         System.err.println(e.toString());
      }
   }
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Securely browsing the net – using SOCKS Bart_ Slackware 2 01-30-2011 05:35 PM
ava.net.ProtocolException: Already connected at gnu.java.net.protocol.http.HTTPURL trfunite Linux - Newbie 0 07-11-2008 06:04 AM
Trying to figure out what is creating Malformed IP packet's on my server bdb4269 Linux - Networking 13 02-16-2008 05:31 AM
SocketException in Java naijaguy Programming 2 02-01-2005 11:34 PM
java.net.SocketException: Connection reset irenequintana Linux - Networking 1 01-10-2005 01:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration