Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MrezeEE.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stdio.h>
- #include <string.h>
- #include <winsock.h>
- #pragma comment(lib, "wsock32.lib")
- 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;
- char* m_sServerIP = "10.10.77.215";
- 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 = inet_addr(m_sServerIP);
- addr_len = sizeof(sockaddr);
- while (true)
- {
- printf("ja: ");
- gets(send_data);
- sendto(sock, send_data, strlen(send_data)+1, 0, (sockaddr*)&server_addr, addr_len);
- bytes_read = recvfrom(sock, recv_data, 1024, 0, (sockaddr*)&client_addr, &addr_len);
- printf("server: %s\n", recv_data);
- }
- closesocket(sock);
- WSACleanup();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement