From 6b11ecb07f5612819635eb48ec26d94d1fc64cf1 Mon Sep 17 00:00:00 2001 From: swarupn Date: Tue, 6 Nov 2018 19:36:20 +0530 Subject: Chore: NGINX demo with multi stack and multi protocol (vpp-hoststck, lwip, kernel) (tcp, udp) Change-Id: I3feb3a88b75b8292e0d7df77e8ed41ee0e2fc0aa Signed-off-by: swarupn --- demo/nginx_proxy/demo-2/udpclient.c | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 demo/nginx_proxy/demo-2/udpclient.c (limited to 'demo/nginx_proxy/demo-2/udpclient.c') diff --git a/demo/nginx_proxy/demo-2/udpclient.c b/demo/nginx_proxy/demo-2/udpclient.c new file mode 100644 index 0000000..76e7b05 --- /dev/null +++ b/demo/nginx_proxy/demo-2/udpclient.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define PORT 53 +#define MAXLINE 1024 + +// Driver code +int +main () +{ + int sockfd; + char buffer[MAXLINE]; + char *hello = "Hello from client"; + struct sockaddr_in servaddr; + + // Creating socket file descriptor + if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0) + { + perror ("socket creation failed"); + exit (EXIT_FAILURE); + } + + memset (&servaddr, 0, sizeof (servaddr)); + + // Filling server information + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons (PORT); + servaddr.sin_addr.s_addr = inet_addr ("192.168.50.20"); + + int n, len; + + sendto (sockfd, (const char *) hello, strlen (hello), + MSG_CONFIRM, (const struct sockaddr *) &servaddr, + sizeof (servaddr)); + printf ("Hello message sent.\n"); + + n = recvfrom (sockfd, (char *) buffer, MAXLINE, + MSG_WAITALL, (struct sockaddr *) &servaddr, &len); + buffer[n] = '\0'; + printf ("Server : %s\n", buffer); + + close (sockfd); + return 0; +} -- cgit