Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by d3vil401

  1. d3vil401

    [HELP] Client not answering back

    Updating: I've been debugging it and destructor is not even being touched.
  2. So i finally made a server but the client is...not answering back.   This is how it works: Clients connect to server, server sends a welcome packet and client answer back with user's credentials. I do the exact same things but the client is not answering back after receiving the server's packet. I'm using Boost::Asio and the error is "End of File" which means the client is shutting down everything. The problem is i don't understand why, i use netsh to redirect client's communications to localhost for testing purpose and Wireshark can't even trace packets so technically the connections does not exist but the server and client can communicate until that error.   Anyone has an idea? Thanks.
  3. d3vil401

    [HELP] Client not answering back

    Thank you, i'll work on it.
  4. d3vil401

    [HELP] Client not answering back

    Well, i actually made already a shared_ptr for the Session type (which is SockHandler class) and it's being passed between all the required classes. Infact, the server successfully sends to the client the packet, but the socket dies after the async_send.
  5. d3vil401

    [HELP] Client not answering back

    What would you do to fix this?
  6. d3vil401

    [HELP] Client not answering back

    Yes and Yes. void Server::Start() { Session tSession(new SockHandler(IOService)); this->Acceptor.async_accept(tSession->getSocket(), boost::bind(&Server::AcceptanceHandler, this, tSession, boost::asio::placeholders::error)); }   void Server::AcceptanceHandler(Session pSession, const boost::system::error_code& error)  { if (!error)  { pSession->Init(); pSession->Start(); this->Start(); } else { printf("[!] AcceptanceHandler Error: %s.\n", error.message().c_str()); } }   bool Server::Initialize(const char* IP, short Port, ConfigManager* CMHandler)  { this->CManager = CMHandler; this->Start(); this->IOService.run(); return true; }
  7. d3vil401

    [HELP] Client not answering back

    It's the server.     Actually i can't just let the client connects to localhost.   void SockHandler::Start()  { printf("Client (%s) successfully connected.\n", REMOTE_IP);   this->StartHeaderReading();   }   void SockHandler::StartHeaderReading() { this->m_recvBuffer.reset(new unsigned char[2]);   boost::asio::async_read(this->tcpSocket, boost::asio::buffer(this->m_recvBuffer.get(), 2), boost::asio::transfer_at_least(1), boost::bind(&SockHandler::StartBodyReading, shared_from_this(), boost::asio::placeholders::error)); }   void SockHandler::StartBodyReading(const boost::system::error_code& error)  { if (!error)  { unsigned short packetLen = ((m_recvBuffer[1] << 8) | m_recvBuffer[0]) - 2; printf("Packet Size: %d\n", packetLen); this->m_recvBuffer.reset(new unsigned char[packetLen]); boost::asio::async_read(this->tcpSocket, boost::asio::buffer(this->m_recvBuffer.get(), packetLen), boost::bind(&SockHandler::ReadHandler, shared_from_this(), packetLen, boost::asio::placeholders::error)); } else { printf("[!] StartBodyReading Error: %s.\n", error.message().c_str()); } }
  8. I'm using my server to use recv() but the client uses instead the WSA* functions. So my client is sending a packet with WSASend() but obv. my server is not able to receive it since it uses recv(). Is there a way to let the server read anyway the packet even using different functions?
  9. http://puu.sh/hyT4f/fa79bf5344.png Did it already, still having the same problem.     Ok i fixed it. I'm sorry, it was not related to my server code nor the client itself but about networking problems.
  10. So this is my problem:   I still have this problem about client not connecting to the server and server not receiving anything. WORD wVersionRequested = MAKEWORD(2, 2); WSAStartup(wVersionRequested, &wsaData);  [...] printf("Starting %s Login Core on %s:%d.\n", CM->getString(CM->SERVER_NAME).c_str(), CM->getString(CM->SERVER_IP).c_str(), CM->getNumber(CM->SERVER_PORT)); InitializeCriticalSection(&gCriticalSection);   s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)); err = ioctlsocket(s, FIONBIO, &iMode);   sin.sin_family = AF_INET; sin.sin_port = CM->getNumber(CM->SERVER_PORT); sin.sin_addr.s_addr = inet_addr(CM->getString(CM->SERVER_IP).c_str());   switch (sin.sin_addr.s_addr) { case INADDR_NONE: printf("[!] Input IP Address is NONE!\n"); break;   case INADDR_ANY: printf("[!] Input IP Address is ANY!\n"); break; }   if (err = ::bind(s, (SOCKADDR*)&sin, sizeof(sin)) == SOCKET_ERROR) { printf("[!] Binding error (%ld).\n", WSAGetLastError()); return 1; }   err = listen(s, SOMAXCONN); if (err == SOCKET_ERROR) { printf("[!] Listening error (%ld).\n", WSAGetLastError()); return 1; }   int fromlen; while (true) {   fromlen = sizeof(from); sock_accept = accept(s, (struct sockaddr*)&from, &fromlen); if (sock_accept != INVALID_SOCKET) { THREAD_STRUCT* th_struct = new THREAD_STRUCT; th_struct->Socket = sock_accept; th_struct->MySQLHandler = DB; th_struct->ChannelsInfo = ChannelsInfo; th_struct->ThreadHandle = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)WinSockThread, th_struct, NULL, &th_struct->SocketRead); }   Sleep(100); } WSACleanup(); } The server is local, so the IP is correct ( for the client AND the server. Client says "unable to connect", my server does not even know there's an incoming connection ( what the hell? ). I tryed to connect to the server trough putty, raw socket on my server IP:Port and the result is "Connection Refused".
  11. Thanks for the information. I will take a look for further explanation for my problem, whenever i need help i will post here.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!