Если ((персонализация(клиент, (структура структуры*)&ампер;server_addr, оператор sizeof(server_addr))) &ЛТ; 0) { соиь <&ЛТ; "=&ГТ; ошибка связывания соединения, розетки уже установлены..." на << епси; возврат -1; }
что это значит
#pragma comment(lib, "Ws2_32.lib") #define _WINSOCK_DEPRECATED_NO_WARNINGS #include <iostream> #include <string.h> #include <sys types.h=""> #include "winsock2.h" #include <ws2tcpip.h> #include <stdlib.h> using namespace std; int main() { int client, server; int portNum = 1500; bool isExit = false; int bufsize = 1024; char buffer[1024]; struct sockaddr_in server_addr; typedef int socklen_t ; socklen_t size; client = socket(AF_INET, SOCK_STREAM, 0); if (client < 0) { cout << "\nError establishing socket..." << endl; } cout << "\n=> Socket server has been created..." << endl; server_addr.sin_family = AF_INET; server_addr.sin_addr.s_addr = htons(INADDR_ANY); server_addr.sin_port = htons(portNum); if ((bind(client, (struct sockaddr*)&server_addr,sizeof(server_addr))) < 0) { cout << "=> Error binding connection, the socket has already been established..." << endl; return -1; } size = sizeof(server_addr); cout << "=> Looking for clients..." << endl; listen(client, 1); int clientCount = 1; server = accept(client,(struct sockaddr *)&server_addr,&size); // first check if it is valid or not if (server < 0) cout << "=> Error on accepting..." << endl; while (server > 0) { strcpy_s(buffer, "=> Server connected...\n"); send(server, buffer, bufsize, 0); cout << "=> Connected with the client #" << clientCount << ", you are good to go..." << endl; cout << "\n=> Enter # to end the connection\n" << endl; cout << "Client: "; do { recv(server, buffer, bufsize, 0); cout << buffer << " "; if (*buffer == '#') { *buffer = '\n'; isExit = true; } } while (*buffer != '\n'); do { cout << "\nServer: "; do { cin >> buffer; send(server, buffer, bufsize, 0); if (*buffer == '#') { send(server, buffer, bufsize, 0); *buffer = '\n'; isExit = true; } } while (*buffer != '\n'); cout << "Client: "; do { recv(server, buffer, bufsize, 0); cout << buffer << " "; if (*buffer == '#') { *buffer = '\n'; isExit = true; } } while (*buffer != '\n'); } while (!isExit); cout << "\n\n=> Connection terminated with IP " << inet_ntoa(server_addr.sin_addr); std::abort(); cout << "\nGoodbye..." << endl; isExit = false; exit(1); } std::abort(); return 0; }
Что я уже пробовал:
Я пытался выполнить его, но в этот момент программа завершается
КАК Я МОГУ ЗАСТАВИТЬ КОД ВЫПОЛНЯТЬСЯ