游戏的服务器怎么能没有密码……
RakNet服务端设置密码:
- if (m_pRakpeerInterface==nullptr)
- {
- std::cout<<"(server) m_pRakpeerInterface is null"<<std::endl;;
- }
- m_pRakpeerInterface->SetIncomingPassword(passwdStr.c_str(),passwdStr.length());
- //start
- m_pRakpeerInterface->Startup(MAX_CLIENTS,&RakNet::SocketDescriptor(SERVER_PORT,0),1);
- m_pRakpeerInterface->SetMaximumIncomingConnections(MAX_CLIENTS);
RakNet客户端使用密码访问:
- //start raknet network connect
- if (m_pRakpeerInterface==nullptr)
- {
- std::cout<<"(client) m_pRakpeerInterface is null"<<std::endl;;
- }
- //startup
- m_pRakpeerInterface->Startup(1,&RakNet::SocketDescriptor(SERVER_PORT,0),1);
- RakNet::ConnectionAttemptResult res= m_pRakpeerInterface->Connect(ipAddrStr.c_str(), SERVER_PORT, passwdStr.c_str(), passwdStr.length());