Cannot send response for each request

29 views
Skip to first unread message

yf z

unread,
May 8, 2023, 5:48:37 PM5/8/23
to WebSocket++
I have a client, which will send 300 requests at the same time;
```
for (int i = 0; i < 300; i++) {
    client.send(hdl, msg[i], opcode::binary);
}
```
I need server give response to each request immediately.
```
void on_msg() {
    server.send(hdl, rsp2msgi, opcode::binary);
}
```
However, server didn't send rsp immediately. There is only one send statement in my code.
BTW, I use protobuf to serialize message so opcode is binary.
What's wrong with my code?

leep

unread,
May 17, 2023, 6:33:42 PM5/17/23
to WebSocket++
Not an expert but sound like you loop clogs the socket with connection with requests. Remember you're asking all this to be sent on ONE connection. You may have to open 500 different connections like in 500 different threads perhaps and do client.send(hdl, msg[i], opcode::binary); for each connection, instead of forcing all one one connection.
Reply all
Reply to author
Forward
0 new messages