added random asset pickerto avServer
This commit is contained in:
parent
cb5b8be40b
commit
277a77134f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
server
|
||||
.vscode
|
||||
.DS_Store
|
||||
package.jpg
|
||||
|
BIN
assets/test1.jpg
Executable file
BIN
assets/test1.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
BIN
assets/test2.jpg
Normal file
BIN
assets/test2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
@ -5,6 +5,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
|
||||
#define PORT 8080
|
||||
|
||||
@ -16,6 +17,8 @@ int main(int argc, char const *argv[])
|
||||
int addrlen = sizeof(address);
|
||||
char buffer[1024];
|
||||
char *overMessage = "over";
|
||||
char files[3][64] = {{"assets/test.jpg"}, {"assets/test1.jpg"}, {"assets/test2.jpg"}};
|
||||
srand(time(NULL));
|
||||
|
||||
// Creating socket file descriptor
|
||||
if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0)
|
||||
@ -49,7 +52,7 @@ int main(int argc, char const *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
printf("accepted\n");
|
||||
int avatar_fd = open("assets/test.jpg", O_RDONLY);
|
||||
int avatar_fd = open(files[rand() % 3], O_RDONLY);
|
||||
if (avatar_fd < 0)
|
||||
{
|
||||
return -1;
|
||||
@ -60,5 +63,8 @@ int main(int argc, char const *argv[])
|
||||
send(new_socket, buffer, sizeof(buffer), 0);
|
||||
}
|
||||
send(new_socket, overMessage, sizeof(overMessage), 0);
|
||||
|
||||
close(server_fd);
|
||||
close(new_socket);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user