UDP and TCP Socket Programming in C with Winsock: Sender and Receiver Examples
Classified in Computers
Written on in
English with a size of 13.97 KB
UDP Sender 1
#include <winsock.h>
#include <stdio.h>
#define msg "This is a UDP message."
int main(int argc, int **argv)
{
WSADATA wsda; // Structure to store info
// returned from WSAStartup
struct hostent *host; // Used to store information
// retrieved about the server
char szMessage[80];
int iMessageLen;
int ret;
char szAddress[64];
int iPort;
SOCKET s; // Our UDP socket handle
SOCKADDR_IN addr; // The host's address
Check Arguments
if(argc != 3 ||
(argc==2 && strcmp((char *) &argv[1][0], "/?")==0))
{
printf("wsudpsnd server port\n");
printf(" server: the server to send the packet to\n");
printf(" port: the port on the remote... Continue reading "UDP and TCP Socket Programming in C with Winsock: Sender and Receiver Examples" »