Hi Coders...
I am new to socket Programming ..I wrote my first program to connect to internic using socket . i am using wifi.plz guide me .here is my code:
int c; Socket s=new Socket("internic.net",43); InputStream in=s.getInputStream(); OutputStream out=s.getOutputStream(); String str="uet.edu.pk"; byte buf[]=str.getBytes(); out.write(buf); // Send request. out.write(buf); // Read and display response. while ((c = in.read()) != -1) { System.out.print((char) c); } s.close(); }
output is:
Exception in thread "main" java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Un known Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress( Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at Whois.main(Whois.java:13)