Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main.cpp
- ____________________________________________________________________________________________________________
- #include "Client.h"
- int main () {
- char cmd[10];
- BOOL ok = true;
- while (ok) {
- printf("Command: ");
- scanf("%s",&cmd);
- if (strcmp(cmd, "client") == 0 || strcmp(cmd, "Client") == 0)
- RunClient();
- /*else if (strcmp(cmd, "server") == 0 || strcmp(cmd, "Server") == 0)
- RunServer();
- else if (strcmp(cmd, "close") == 0 || strcmp(cmd, "Close") == 0) {
- CloseServer();
- ok = false;
- }*/
- else
- printf("Invalid arguments\r\nUse with arguments client, server or close\r\n");
- }
- return 0;
- }
- Client.cpp
- ____________________________________________________________________________________________________________
- #include "Client.h"
- int ReadInput() {
- char buffer [5];
- printf("Number: ");
- fgets(buffer,5,stdin);
- return atoi(buffer);
- }
- void RunClient() {
- int number;
- int i = 5;
- while (i != 0) {
- number = ReadInput();
- printf("Number is: %d\n",number);
- i--;
- }
- }
- Common.h
- ____________________________________________________________________________________________________________
- #pragma once
- #define CONNECT_NAMEDPIPE "\\\\.\\pipe\\ClientToServer"
- #include <stdio.h>
- #include <windows.h>
- struct Msg {
- int value[10];
- int length;
- };
- struct MinMax {
- int min;
- int max;
- };
- Client.h
- ____________________________________________________________________________________________________________
- #include "Common.h"
- void RunClient();
- void CloseServer();
Advertisement
Add Comment
Please, Sign In to add comment