• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help me out for the socket connection  RSS feed

 
sukhavasi vasavi
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam new to Socket Connection in java.
while Iam going to create the socket connection ,it is throwing an exception.
Could you please tell me the problem in this program?

import java.net.*;
import java.io.*;
public class Whois {

public static void main(String[] args)throws Exception {

Socket s=new Socket("www.yahoomail.com",80);
System.out.println(s.getInetAddress());
System.out.println(s.getPort());

}

}
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not tell us what the exception message is? It would save everybody a lot of time, not having to guess.
 
sukhavasi vasavi
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is throwing java.net.ConnectException .Please help me to solve this problem?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, since that's a valid host name that does indeed listen on port 80, perhaps your computer is behind a firewall that does not allow outbound connections on port 80, and would require you to use a proxy server. Ask your network admin if this is the case.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!