Pero no me devuelve bien el accept, me devuelve SOCKET_ERROR por toda la eternidad
Anda todo PERFECTO excepto el ACCEPT, tal vez este poniendo mal algun dato como IP o puerto, si me pueden dar una mano agradeceria
vars...
Código C++:
Ver original
SOCKET serverSocket, serverBackup; SOCKET acceptSocket; SOCKET clientSocket; WSADATA socketData; sockaddr_in hostAddress; sockaddr_in clientAddress; sockaddr_in serverAddress; char* hipAddress="0.0.0.0"; char* ipAddress="127.0.0.1"; int port=100; hostAddress.sin_family=domain; hostAddress.sin_addr.s_addr=inet_addr(hipAddress); hostAddress.sin_port=htons(port); clientAddress.sin_family=domain; clientAddress.sin_addr.s_addr=inet_addr(ipAddress); clientAddress.sin_port=htons(port); serverAddress=clientAddress;
execution..
Código C++:
Ver original
iniSock(serverSocket); Bind(serverSocket, &hostAddress); // anda bien Listen(serverSocket); // anda bien serverBackup=serverSocket; Accept(serverSocket, &clientAddress); // anda mal -_-
function..
Código C++:
Ver original
void Accept(SOCKET& sock, sockaddr_in* Address) { cout << endl << "Accepting.." << endl; acceptSocket=accept(serverBackup, (SOCKADDR*)Address, (int*)sizeof(*Address)); //acceptSocket=accept(sock, NULL, NULL); while(acceptSocket==SOCKET_ERROR) { acceptSocket=accept(serverBackup, (SOCKADDR*)Address, (int*)sizeof(*Address)); //acceptSocket=accept(sock, NULL, NULL); } // este bucle es eterno :( sock=acceptSocket; cout << "Accepted!!" << endl << endl; }
saludos!!