I am doing almost exactly the same thing in a servlet, but I am using
whois.internic.net as the whois server. Are you sure rs.internic.net will
work? Try telnetting to it on that port? I am also using a BufferedReader
to read the input, do not know if that makes any difference. Can you stick
debug code in your servlet to see where it is hanging?
HTH. Good luck.
----- Original Message -----
From: Kalyan Rizvanovich < >
To: <[EMAIL PROTECTED]>
Sent: Friday, May 12, 2000 2:02 AM
Subject: Socket connection quesiton
> Dear Gurus,
> I'm sorry to bother you with this
> quesiton again, but it is imperative
> for me to find the solution fast.
>
> When I create the socket connection to
> whois server and thy to read from
> the InputStream, it takes a very long time
> and then returns some "connection timed out"
> error. Can it be because I am running that
> directly from the servlet.
> O'Reilly's book has a very simillar example,
> but they use an applet with a servlet(daytime
> server)?
> Can somebody tell me the right way of doing it?
> Maybe I should approach reading from a socket in
> another way?
>
> Here is the full code:
>
> import java.net.*;
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public
> class whoisSuccess2 extends HttpServlet {
>
>
> public void init(ServletConfig config) throws ServletException {
> super.init(config);
> }
>
> public void doGet (HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException
> {
>
> res.setContentType("text/html");
> String dome = req.getParameter("dome");
>
> ServletOutputStream output = res.getOutputStream();
>
> int c;
> Socket s = new Socket("rs.internic.net",43);
> InputStream in = s.getInputStream();
> OutputStream out = s.getOutputStream();
> String str = "kalyan.com";
> byte buf[] = str.getBytes();
> out.write(buf);
> String strRawResponse = "";
>
>
> while ((c = in.read()) != -1) {
> strRawResponse += (char)c;
> }
> output.println("<html>");
> output.println("<head><title>Whois</title></head>");
> output.println("<body>");
> output.println(strRawResponse);
> output.println("</body></html>");
>
>
> }
> }
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets