diff --git a/src/client/main.cc b/src/client/main.cc new file mode 100644 index 0000000..552bf17 --- /dev/null +++ b/src/client/main.cc @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include +#include + +using std::cout, std::cin, std::endl, std::string; + +int main() { + + struct Message { + char * content; + string username; + }; + + int clientSocket = socket(AF_INET, SOCK_STREAM, 0); + + sockaddr_in serverAdress; + serverAdress.sin_family = AF_INET; + serverAdress.sin_port = htons(8080); + serverAdress.sin_addr.s_addr = inet_addr("127.0.0.50"); + + while (true) { + Message message; + cout << "Type message to server: "; + cin >> message.content; + cout << endl; + message.username = "Client 1"; + + if (strcmp(message.content, "exit") == 0) { + break; + } + + cout << "Sending message to server as user: " << message.username << endl; + send(clientSocket, message.content, strlen(message.content), 0); + } + + close(clientSocket); + + return 0; +}