UDP-клиент-сервер в Windows, один поток для приема, другой для отправки ⇐ C++
UDP-клиент-сервер в Windows, один поток для приема, другой для отправки
I can send and receive data on different threads using the TCP protocol as demonstrated in the following code, how can I do the same using the UDP protocol?
#include #include #include using namespace std; // Function that receive data from client
DWORD WINAPI serverReceive(LPVOID lpParam) { // Created buffer[] to // receive message char buffer[1024] = { 0 }; // Created client socket SOCKET client = *(SOCKET*)lpParam; // Server executes continuously while (true) { // If received buffer gives // error then return -1 if (recv(client, buffer, sizeof(buffer), 0) == SOCKET_ERROR) { cout
Источник: https://stackoverflow.com/questions/780 ... er-to-send
I can send and receive data on different threads using the TCP protocol as demonstrated in the following code, how can I do the same using the UDP protocol?
#include #include #include using namespace std; // Function that receive data from client
DWORD WINAPI serverReceive(LPVOID lpParam) { // Created buffer[] to // receive message char buffer[1024] = { 0 }; // Created client socket SOCKET client = *(SOCKET*)lpParam; // Server executes continuously while (true) { // If received buffer gives // error then return -1 if (recv(client, buffer, sizeof(buffer), 0) == SOCKET_ERROR) { cout
Источник: https://stackoverflow.com/questions/780 ... er-to-send
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Какова структура, которая хранится в буферах отправки/приема сокета UDP?
Anonymous » » в форуме Linux - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-