I am emulating lots of clients by using the following code:
int select_ret = select(0, &fds, 0, 0, &timeout);
if (SOCKET_ERROR == select_ret)
{
cout << " Socket select error." << endl;
cleanup();
return 7;
}
else if (0 < select_ret)
{
int temp_bytes_received = 0;
if (SOCKET_ERROR == (temp_bytes_received = recvfrom(udp_socket, &rx_buf[0], rx_buf_size, 0, reinterpret_cast<struct sockaddr*>(&their_addr), &addr_len)))
{
cout << " Socket recvfrom error." << endl;
cleanup();
return 8;
}
ostringstream oss;
oss << "127.";// static_cast<int>(their_addr.sin_addr.S_un.S_un_b.s_b1) << ".";
oss << "0.";// static_cast<int>(their_addr.sin_addr.S_un.S_un_b.s_b2) << ".";
oss << "0.";// static_cast<int>(their_addr.sin_addr.S_un.S_un_b.s_b3) << ".";
oss << rand() % 256;// static_cast<int>(their_addr.sin_addr.S_un.S_un_b.s_b4);
...
Does anyone have another way of testing many clients, without having actual clients?