problem with websocket sample program

Mar 18, 2015 at 4:11 AM
I took the code in the documentation for websockets and created the following:
#include "stdafx.h"
#include <cpprest/ws_client.h>
using namespace web;
using namespace web::websockets::client;

int _tmain(int argc, _TCHAR* argv[])

    websocket_client client();
    websocket_outgoing_message msg;

    client.connect(U("ws://localhost:9090")).then([](){ /* We've finished connecting. */ });

    msg.set_utf8_message("I am a UTF-8 string! (Or close enough...)");
    client.send(msg).then([](){ /* Successfully sent the message. */ });

    client.receive().then([](websocket_incoming_message msg) {
        return msg.extract_string();
    }).then([](std::string body) {
        std::cout << body << std::endl;

    client.close().then([](){ /* Successfully closed the connection. */ });
    return 0;
When I try and compile it I get the following errors for every line that references client.

test.cpp(13): error C2228: left of '.connect' must have class/struct/union

I am new to the task so I am still not 100% sure I am doing everything right

Any help would be appreciated

Mar 18, 2015 at 3:40 PM
ok, now I feel dumb. The solution was to change

websocket_client client();


websocket_client client;

I guess the cpp skills are a little rusty. Too much time in the C world I guess.

I know I need to wait for the async tasks to complete.