/* valac --pkg gio-2.0 test-example.vala */

public void main (string[] args) {
    Socket socket;
    SocketClient client;
    SocketSource source;
    SocketConnection connection;

    client = new SocketClient ();
    try {
        connection = client.connect_to_host ("www.google.com", 80, null); 
        socket = connection.get_socket ();
        source = (SocketSource) socket.create_source (IOCondition.IN, null);
        assert (source != null);
        source.set_callback ((sock,cond) => {
            print ("Data received...\n");
            return true;
        });
        source.attach (MainContext.default ());
    } catch (Error e) {
        stderr.printf ("%s\n", e.message);
    }

/*
    var loop = new MainLoop ();
    loop.run ();
*/
}
