✨ Make server continous
This commit is contained in:
parent
3b782e664a
commit
63bd78aeb0
1 changed files with 7 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <ostream>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -8,12 +9,7 @@ using std::cout, std::endl, std::string;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
struct Message {
|
cout << "Initializing server" << endl;
|
||||||
string content;
|
|
||||||
string username;
|
|
||||||
};
|
|
||||||
|
|
||||||
cout << "Initializing server";
|
|
||||||
int serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
int serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (serverSocket == -1) {
|
if (serverSocket == -1) {
|
||||||
// TODO error
|
// TODO error
|
||||||
|
@ -40,9 +36,11 @@ int main() {
|
||||||
// TODO error
|
// TODO error
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[1024] = { 0 };
|
while (true) {
|
||||||
|
char buffer[1024] = {0};
|
||||||
recv(clientSocket, buffer, sizeof(buffer), 0);
|
recv(clientSocket, buffer, sizeof(buffer), 0);
|
||||||
cout << "Message from client " << buffer << endl;
|
cout << buffer << endl;
|
||||||
|
}
|
||||||
|
|
||||||
close(serverSocket);
|
close(serverSocket);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue