Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include "client.h"
- #include <string.h>
- #include <pthread.h>
- int main(int argc, char** argv) {
- int fd_s, fd_c;
- char * myfifo = "/tmp/myfifo";
- request requ;
- char c_pid[10];
- sprintf(c_pid, "%d", getpid());
- requ.client_pid = getpid();
- fd_s = open(myfifo, O_WRONLY);
- // mkfifo(myfifo, 0666); /* create the FIFO (named pipe) */
- printf("<<<<<<<<<<<<Client>>>>>>>>>>>>\n\n\n");
- printf("> Welcome to Bomberman! Input commands as you wish!\n");
- while (1) {
- printf("\n> ");
- scanf(" %s", requ.command);
- if (strcmp(requ.command, "login") == 0) {
- printf("\n> Username : ");
- scanf(" %s", requ.user_username);
- printf("\n> Password : ");
- scanf(" %s", requ.user_password);
- write(fd_s, &requ, sizeof (request));
- read(fd_c, &requ, sizeof(request));
- printf("%s", requ.answer);
- }
- if (strcmp(requ.command, "shutdown") == 0) {
- exit(1);
- }
- }
- close(fd_c);
- close(fd_s);
- unlink(myfifo); /* remove the FIFO */
- return (EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement