Hello, I am writting a client\server application(game) using openssl API for the network. I am ablie to connect with openssl s_client to openssl s_server. I am also able to connect with my own game client to openssl s_server(with the same parameters). However, I am unable to accept any connection with my game server. Specifically it gets stuck on the function BIO_do_accept. I don't think it's a problem of port mismatch. I also disabled the firewall. I don't know what else it could be.
Here is the source code for the server. It got some code that isn't part of this problem, but I wanted to post the "Real thing"
void IPHost::SetupNetwork() { int Port = GetPort(); int TCPPort = GetTCPPort(); localHost = NULL; memset (&wsaData, 0, sizeof(wsaData)); int rc=0; //--------------------------------------------- // Initialize Winsock // Load Winsock rc = WSAStartup(MAKEWORD(2, 2), &wsaData); GlobalErrorWrap::Assert (rc==0, _T("Unable to load Winsock: %d\n")); SendToSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); GlobalErrorWrap::Assert (SendToSocket != INVALID_SOCKET, _T("socket failed: %d\n")); localHost = gethostbyname(_T("")); ip = inet_ntoa(*(struct in_addr *) *localHost->h_addr_list); int v = SSL_library_init(); SSL_load_error_strings(); ERR_load_BIO_strings(); SpecificSetup(Port, TCPPort); } void Server::SpecificSetup (int A_Port, int A_TCPPort) { ctx = SSL_CTX_new(SSLv23_server_method()); AssertSSL (ctx!=NULL, "Failed to create OpenSSL context"); SSL * ssl; int r = SSL_CTX_use_certificate_file(ctx, "Wonder.pem", SSL_FILETYPE_PEM); AssertSSL (r>=1, "Failed to load public certificate"); r = SSL_CTX_use_PrivateKey_file(ctx, "Wonder.pem", SSL_FILETYPE_PEM); AssertSSL (r>=1, "Failed to load private key"); AssertSSL ((bio = BIO_new_ssl(ctx, 0))!=NULL, "Failed to create server bio"); BIO_get_ssl(bio, &ssl); SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); std::ostringstream OStr; OStr<<A_TCPPort; char c[256]; strcpy (c, OStr.str().c_str()); abio = BIO_new_accept("4516"); BIO_set_accept_bios(abio, bio); AssertSSL (BIO_do_accept(abio)>0, "Cannot bind server"); AssertSSL (BIO_do_accept(abio)>0, "asdlkjasd"); // Get stuck here. GlobalErrorWrap::Assert (false, "Good!"); struct sockaddr_in LocalAddr; int LocalAddrSize = sizeof (LocalAddr); LocalAddr.sin_family = AF_INET; // LocalAddr.sin_addr.s_addr = inet_addr(ip); LocalAddr.sin_addr.s_addr = inet_addr("0.0.0.0"); LocalAddr.sin_port = htons((unsigned short)A_Port); //TODO: Conversion error? int rc = bind(SendToSocket, (struct sockaddr *) &LocalAddr, LocalAddrSize); GlobalErrorWrap::Assert (rc != SOCKET_ERROR, _T("bind failed: %d\n")); }