Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main(int argc, char* argv[])
- {
- WSAData wsa;
- WSAStartup(0x0202, &wsa);
- SOCKET sock;
- int addr_len, bytes_read;
- char recv_data[1024];
- char send_data[1024];
- sockaddr_in server_addr, client_addr;
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == SOCKET_ERROR)
- {
- return;
- }
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = htons(5000);
- server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- if (bind(sock, (sockaddr*)&server_addr, sizeof(sockaddr_in)) == SOCKET_ERROR)
- {
- return;
- }
- addr_len = sizeof(sockaddr);
- while (true)
- {
- bytes_read = recvfrom(sock, recv_data, 1024, 0, (sockaddr*)&client_addr, &addr_len);
- //nesto
- sendto(sock, send_data, strlen(send_data), 0, (sockaddr*)&client_addr, sizeof(sockaddr));
- }
- closesocket(sock);
- WSACleanup();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement