scripter73
Programmer
I'm learning sockets. I have gone through I don't know how many socket tutorials, all offering advice on how to connect to a server through a "socket". I can't get any of them to work. Does anyone have a full-proof code where I can just see this work? It always seems that the ip addresses/url provided are out of date, etc. Here's the latest that doesn't work:
import java.io.*; // These two are needed for socket support
import java.net.*;
public class Client
{
public static void main(String args[])
{
try
{
Socket s = new Socket("time-A.timefreq.bldrdoc.gov", 13);
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
String line;
while(( line = in.readLine()) != null)
System.out.println(line);
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
Any help's appreciated.
Change Your Thinking, Change Your Life.
import java.io.*; // These two are needed for socket support
import java.net.*;
public class Client
{
public static void main(String args[])
{
try
{
Socket s = new Socket("time-A.timefreq.bldrdoc.gov", 13);
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
String line;
while(( line = in.readLine()) != null)
System.out.println(line);
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
Any help's appreciated.
Change Your Thinking, Change Your Life.