[java]代码库
public class MySocket extends TcpSocket
{
public MySocket(SocketHandler h)
{
super(h);
SetLineProtocol();
}
public void OnConnect()
{
Send("GET / HTTP/1.0\r\n" +
"Host: www.alhem.net\r\n" +
"\r\n");
}
public void OnLine(String line)
{
System.out.println(line);
}
public static void main(String[] args)
{
StdLog log = new StdoutLog();
SocketHandler h = new SocketHandler(log);
MySocket sock = new MySocket(h);
sock.Open( "www.yuncode.net", 80 );
h.Add( sock );
boolean quit = false;
while (!quit) // forever
{
h.Select(1, 0);
}
}
}
//源代码片段来自云代码http://yuncode.net