Well, I need a clarify of what is the importance of the \"\\n\" new line in the String variable here
import java.net.*;
import java.io.*;
The newline has no importance in Java networking.
However it does have importance in many protocols, many of which are based on the 'Telnet Terminal' convention of \r\n
as the line terminator. This certainly includes SMTP, FTP, HTTP, and Telnet itself.
It also has importance for the BufferedReader.readLine()
method. You will find hundreds of questions here about readLine()
blocking forever, to which the answer is 'you are reading lines but you are not writing lines', i.e. just sending a string with no line terminator. This does not constitute a complete line, so readLine()
doesn't return it.
TCP port 43 is the WHOIS protocol explained here on Wikipedia: Whois
If you see the article is says: Send a single "command line", ending with CRLF.
That's why you need the newline in your code.