Share this page

# Example: web_websocket_connect, web_websocket_close, web_websocket_send

In the following example, the Vuser creates a WebSocket, sends a message, and then closes it.

    #include "as_web.h"

    Action()
    {
    web_websocket_connect("ID=0", "URI=ws://pumpkin:9876/", "Origin=http://pumpkin:9876", "OnOpenCB=OnOpenCB0", "OnMessageCB=OnMessageCB0", "OnErrorCB=OnErrorCB0", "OnCloseCB=OnCloseCB0", LAST);
    web_websocket_send("ID=0", "Buffer=sample text message", "IsBinary=0", LAST);
    web_websocket_send("ID=0", "Buffer/File={myfile}", "IsBinary=0", LAST);
    /*Connection ID 0 received buffer WebSocketReceive0*/
    lr_think_time(7);
    web_websocket_close("ID=0", "Code=1000", "Reason=OK", LAST);
    return 0;
    }

Tips to improve your search results... VuGen Function Reference Version 25.1-25.3 Function Reference 25.1-25.3 All View Local Help Center View Online Help Center Version: