changeset 0:41118bca4f06

Initial import
author Josef "Jeff" Sipek <jeffpc@optonline.net>
date Fri, 26 Aug 2005 13:56:45 -0500
parents
children 32210a783cf7
files Makefile main.c
diffstat 2 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Fri Aug 26 13:56:45 2005 -0500
@@ -0,0 +1,9 @@
+CC=gcc
+CFLAGS=-Wall
+
+all:
+	$(CC) $(CFLAGS) -o pset main.c
+
+clean:
+	rm -f pset *.o *~
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.c	Fri Aug 26 13:56:45 2005 -0500
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <unistd.h>
+
+#define RCON_PASSWORD "foo;bar"
+#define RCON_PORT 27960
+#define RCON_HOST "127.0.0.1"
+
+int main(int argc, char** argv)
+{
+	int sockfd;
+	struct sockaddr_in dest_addr;
+	char *buf;
+
+	buf = (char*) malloc(sizeof(char)*getpagesize());
+	if (!buf) {
+		fprintf(stderr,"OOM\n");
+		return 1;
+	}
+	
+	sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+
+	dest_addr.sin_family = AF_INET;
+	dest_addr.sin_port = htons(RCON_PORT);
+	dest_addr.sin_addr.s_addr = inet_addr(RCON_HOST);
+	memset(&(dest_addr.sin_zero), '\0', 8);
+
+	connect(sockfd, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr));
+	strcpy(buf, "\xff\xff\xff\xffrcon foo;bar status");
+	write(sockfd, buf, strlen(buf));
+	while(1) {
+		int ret;
+		ret = read(sockfd, buf, 250);
+		printf("%d bytes: %s\n",ret, buf);
+	}
+	
+	return 0;
+}