<commit_before>#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<stdlib.h>
#include<netdb.h>
#include<strings.h>
#include<string.h>

#define MAXBUF 1024

int main(int argc, char *argv[]) {

	int	clntSockId;
	struct sockaddr_in	servSockAddr, clntSockAddr;
	int servPort;
	int retStatus;
	int servSockLen;
	char buf[MAXBUF];

	/* Check for cmd line options */
	if (argc != 3) {
		fprintf(stderr, "Usage : %s <ServerAddr> <ServerPort>\n", argv[0]);
		exit(1);
	}
	
	/* Create Client Socket */
	clntSockId = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if(clntSockId != -1) {
		fprintf(stdout, "Client Socket Created : %d \n", clntSockId);
	} else {
		fprintf(stderr, "Client Socket Creation Failed!\n");
		exit(1);
	}

	/* Initialize Server sockaddr_in. User INADDR_ANY to bind to
		 all local addresses */
	servPort = atoi(argv[2]);
	bzero(&servSockAddr, sizeof(servSockAddr));
	servSockAddr.sin_family = AF_INET;
	inet_addr(argv[1], servSockAddr.sin_addr.s_addr);
	servSockAddr.sin_port = htons(servPort);
	servSockLen = sizeof(servSockAddr);

	strcpy(buf, "Hello from client\n");
	/* Send data to server */
	retStatus = sendto(clntSockId, buf, strlen(buf)+1, 0, 
									(struct sockaddr *) &servSockAddr, 
									 sizeof(servSockAddr));
	if(retStatus > 0) {
		fprintf(stdout, "Message sent to server\n"); 
	} else {
		fprintf(stderr, "Couldn't send message to server\n");
		close(clntSockId);
		exit(1);
	}

	/* Receive data from server */
	bzero(&buf, MAXBUF);
	retStatus = recvfrom(clntSockId, buf, MAXBUF, 0, 
									(struct sockaddr *)&servSockAddr, &servSockLen);
	if(retStatus > 0) {
		fprintf(stdout, "%d Bytes received from server %s\n", retStatus, buf);<commit_msg>Changes to udp client<commit_after>#include<stdio.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<stdlib.h>
#include<netdb.h>
#include<strings.h>
#include<string.h>

#define MAXBUF 1024

int main(int argc, char *argv[]) {

	int	clntSockId;
	struct sockaddr_in	servSockAddr, clntSockAddr;
	int servPort;
	int retStatus;
	int servSockLen;
	char buf[MAXBUF];

	/* Check for cmd line options */
	if (argc != 3) {
		fprintf(stderr, "Usage : %s <ServerAddr> <ServerPort>\n", argv[0]);
		exit(1);
	}
	
	/* Create Client Socket */
	clntSockId = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if(clntSockId != -1) {
		fprintf(stdout, "Client Socket Created : %d \n", clntSockId);
	} else {
		fprintf(stderr, "Client Socket Creation Failed!\n");
		exit(1);
	}

	/* Initialize Client sockaddr_in. User INADDR_ANY to bind to
		 all local addresses */
	bzero(&clntSockAddr, sizeof(clntSockAddr));
	clntSockAddr.sin_family = AF_INET;
	clntSockAddr.sin_addr.s_addr = INADDR_ANY;
	clntSockAddr.sin_port = 0;

	/* bind client socket */
	retStatus = bind(clntSockId, (struct sockaddr *)&clntSockAddr, 
								sizeof(clntSockAddr));
	if(retStatus == 0) {
		fprintf(stdout, "bind client socket\n");
	} else {
		fprintf(stderr, "Couldn't bind client socket\n");
		exit(1);
	}

	/* Initialize Server sockaddr_in. User INADDR_ANY to bind to
		 all local addresses */
	servPort = atoi(argv[2]);
	bzero(&servSockAddr, sizeof(servSockAddr));
	servSockAddr.sin_family = AF_INET;
	inet_addr(argv[1], servSockAddr.sin_addr.s_addr);
	servSockAddr.sin_port = htons(servPort);
	servSockLen = sizeof(servSockAddr);

	strcpy(buf, "Hello from client\n");
	/* Send data to server */
	retStatus = sendto(clntSockId, buf, strlen(buf)+1, 0, 
									(struct sockaddr *) &servSockAddr, 
									 sizeof(servSockAddr));
	if(retStatus > 0) {
		fprintf(stdout, "Message sent to server\n"); 
	} else {
		fprintf(stderr, "Couldn't send message to server\n");
		close(clntSockId);
		exit(1);
	}

	/* Receive data from server */
	bzero(&buf, MAXBUF);
	retStatus = recvfrom(clntSockId, buf, MAXBUF, 0, 
									(struct sockaddr *)&servSockAddr, &servSockLen);
	if(retStatus > 0) {
		fprintf(stdout, "%d Bytes received from server %s\n", retStatus, buf);
{'fraction_non_alphanumeric': 0.14512008175779254, 'fraction_numerical': 0.009453244762391415, 'mean_word_length': 4.4299583911234395, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1632331', 'n_tokens_mistral': 1625, 'n_tokens_neox': 1464, 'n_words': 341}