Compare commits

..

5 commits

Author SHA1 Message Date
516dd498c2 remove extra null byte
i have no clue why i put that there
2022-03-14 19:45:47 -04:00
3a2abc58e8 support ipv6 2022-02-18 20:16:14 -05:00
527cd1c5f3 remove unnessesary whitespace 2022-01-29 21:32:07 -05:00
7d31364977 fix compiling on musl 2022-01-16 11:52:22 -05:00
548abe4349 pad color output with zeros to be at least 6 letters long 2021-12-03 08:59:54 -05:00

View file

@ -1,4 +1,5 @@
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -63,7 +64,7 @@ void *handle_connection(void *socket_desc) {
if (xpos >= 0 && ypos >= 0 && xpos < fb_width && ypos < fb_height) {
if (colorcode[0] == '\0') {
sprintf(message, "PX %i %i %X\n",xpos,ypos,fbdata[ypos*fb_length+xpos]);
sprintf(message, "PX %i %i %06X\n",xpos,ypos,fbdata[ypos*fb_length+xpos]);
write(sock, message, strlen(message));
continue;
} else {
@ -76,7 +77,7 @@ void *handle_connection(void *socket_desc) {
continue;
}
if (!strcmp("SIZE", command)) {
sprintf(message, "SIZE %i %i\n\0", fb_width, fb_height);
sprintf(message, "SIZE %i %i\n", fb_width, fb_height);
write(sock, message, strlen(message));
continue;
}
@ -126,15 +127,15 @@ int main(int argc, char *argv[]) {
memset(fbdata, 0, fb_data_size); // clear the screen
int socket_desc, client_sock, c;
struct sockaddr_in server, client;
struct sockaddr_in6 server, client;
socket_desc = socket(AF_INET, SOCK_STREAM, 0);
socket_desc = socket(AF_INET6, SOCK_STREAM, 0);
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons(port);
server.sin6_family = AF_INET6;
server.sin6_addr = in6addr_any;
server.sin6_port = htons(port);
struct timeval tv;
tv.tv_sec = 60;