Commit 11d06cfe authored by Paul Michel's avatar Paul Michel
Browse files

connecting works now

parent 967be693
pixelflut-c: main.o
gcc -o pixelflut-c main.o
CC = gcc -g
pixelflut-c: main.o pixelflut.o
$(CC) -o pixelflut-c main.o pixelflut.o
main.o: main.c
gcc -c main.c -o main.o
\ No newline at end of file
$(CC) -c main.c -o main.o
pixelflut.o: pixelflut.c
$(CC) -c pixelflut.c -o pixelflut.o
\ No newline at end of file
......@@ -6,5 +6,13 @@
int main(void)
{
printf("This is supposed to become a pixelflut client in C.\n");
int retval = pixelflut("141.24.52.16", 1234);
if (retval) {
printf("Something went wronk\n");
return 1;
}
return 0;
}
\ No newline at end of file
# include "pixelflut.h"
#include "pixelflut.h"
int pixelflut(char* destination, int port)
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
int pixelflut(char* dest_str, int port)
{
struct sockaddr_in dest;
memset(&dest, 0, sizeof(dest));
dest.sin_family = AF_INET;
inet_aton(dest_str, &dest.sin_addr);
dest.sin_port = htons(port);
int mysocket = socket(AF_INET, SOCK_STREAM, 0);
if (connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr_in)) < 0) {
printf(strerror(errno));
printf("\n");
return -1;
}
}
\ No newline at end of file
int pixelflut(char* destination, int port);
\ No newline at end of file
int pixelflut(char* dest_str, int port);
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment