-
-
Save xymostech/41a005936bf52ac10cca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while(consocket){ | |
/* read the joystick state */ | |
read(joy_fd, &js, sizeof(struct js_event)); | |
/* see what to do with the event */ | |
switch (js.type & ~JS_EVENT_INIT) | |
{ | |
case JS_EVENT_AXIS: | |
axis [ js.number ] = js.value; | |
break; | |
case JS_EVENT_BUTTON: | |
button [ js.number ] = js.value; | |
break; | |
} | |
//Give msg1 variable the value of axis[0] | |
sprintf(msg1, "%d", axis[0]); | |
//TCP send | |
char msg[] = "Hello"; | |
printf("Value is: %d\n", axis[0]); | |
//printf("Incoming connection from %s - sending welcome\n", inet_ntoa(dest.sin_addr)); | |
send(consocket, msg1, strlen(msg1), 0); | |
close(consocket); // THIS IS THE IMPORTANT LINE | |
consocket = accept(mysocket, (struct sockaddr *)&dest, &socksize); | |
printf("Value X is: %s\n", msg1); | |
printf(" \r"); | |
fflush(stdout); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment