Skip to main content

Posts

Showing posts from 2015

UDP Server-Client Communication in C++

This is sample code for UDP Server and Client Communication in C++. Things to keep in mind : First Run server and then client If you receive error 10054 while running client, it is because of recvfrom() in client.cpp , as it is trying to receive from null reference. Either comment out recvfrom() or start server first. //============================================================================ // Name : Simple C++ UDP Server.cpp // Author : Manish Kumar Khedawat //============================================================================ #include "stdafx.h" #include <iostream> #include <winsock2.h> #include<stdio.h> #define BUFLEN 512 #pragma comment(lib,"ws2_32.lib") //Winsock Library, To Avoid Error in Visual Studio Compilation using namespace std; int main () { WSAData version; //WSAData is Structure which holds the information about windows socket implementation WORD mkword = MAKE...