Q:

About control symbols

Hi.
I have this code for example, it is working correctly:
   class main {
           public static void main(String args[]) throws Exception {
        Socket socks = new Socket("whois.internic.net", 43);
    InputStream in = socks.getInputStream();
    OutputStream out = socks.getOutputStream();
    String str    ;
    str= "MHProfessional.com"+"\n";
    byte buf[] = str.getBytes();
    out.write(buf);

    int c;
    while ((c = in.read()) != -1) {
        System.out.print((char) c);
    }
    //socks.close();

but when I delete  this: +"\n" . then my program id not working and I see blank screen . So why? 

A:

Because the protocol specification says that

A WHOIS server listens on TCP port 43 for requests from WHOIS
     clients.  The WHOIS client makes a text request to the WHOIS server,
     then the WHOIS server replies with text content.  All requests are
     terminated with ASCII CR and then ASCII LF.

So the server waits for the end of line before replying. So if you never send the end of line, you'll never get an answer.
Note that the server could even have rejected your request, since you're sending an LF, but without sending a CR before. The request should be "MHProfessional.com\r\n".

