[java]代码库
import java.io.IOException;import java.io.InputStream;import java.net.Socket;import java.util.Scanner;public class SocketTest
{ public static void main(String[] args)
{ try
{
Socket s = new Socket("time-A.timefreq.bldrdoc.gov",13); try
{
InputStream inStream = s.getInputStream();
@SuppressWarnings("resource")
Scanner scanner = new Scanner(inStream);
while (scanner.hasNextLine())
{
String line = scanner.nextLine();
System.out.println(line);
}
} finally
{
s.close();
}
} catch (IOException e)
{
e.printStackTrace();
}
}
}//源代码片段来自云代码http://yuncode.net