Jump to content

Small Fix About Connect


Ken

Recommended Posts

Hi, everyone. Most people know when you are trying to connect the server with a lot of people, the server can not respond to you or something might go wrong. This example is same for warp too. Webzen did something about this too and I'd like to share it with you.

What are exactly are we doing?

If the client can not connect to the server, the client will wait one second to connect the server again.

Open NetStream.cpp. Find Connect function and replace with this

bool CNetworkStream::Connect(const CNetworkAddress& c_rkNetAddr, int limitSec)
{
	Clear();

	m_addr = c_rkNetAddr;

	m_sock = socket(AF_INET, SOCK_STREAM, 0);

	if (m_sock == INVALID_SOCKET)
	{
		Clear();
		OnConnectFailure();
		return false;
	}

	DWORD arg = 1;
	ioctlsocket(m_sock, FIONBIO, &arg);	// Non-blocking mode

	if (connect(m_sock, reinterpret_cast<PSOCKADDR>(&m_addr), m_addr.GetSize()) == SOCKET_ERROR)
	{
		int error = WSAGetLastError();

      	// If something went wrong, the client will wait one second to connect the server again.
      	// Of course, it will clear and setting up everything again.
		if (error != WSAEWOULDBLOCK)
		{
			Sleep(1000);
			Clear();
			m_sock = socket(AF_INET, SOCK_STREAM, 0);
			if (m_sock == INVALID_SOCKET)
			{
				Clear();
				OnConnectFailure();
				return false;

			}

			ioctlsocket(m_sock, FIONBIO, &arg);
			if (connect(m_sock, reinterpret_cast<PSOCKADDR>(&m_addr), m_addr.GetSize()) == SOCKET_ERROR)
			{
				Tracen("error != WSAEWOULDBLOCK");
				Clear();
				OnConnectFailure();
				return false;
			}
		}
	}

	m_connectLimitTime = time(NULL) + limitSec;
	return true;	
}

Best Regards

Ken

  • Love 17

Do not be sorry, be better.

Link to comment
Share on other sites

  • 6 months later...
  • Premium
On 1/7/2017 at 6:07 PM, Ken said:

when you are trying to connect the server with a lot of people

 

 

52 minutes ago, Cyber36 said:

How can I test this bug on my server? (To test the fix?)

MfG

Cyber

 

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • 2 years later...

Announcements



  • Similar Content

  • Similar Content

  • Similar Content

  • Tags

  • Activity

    1. 113

      Ulthar SF V2 (TMP4 Base)

    2. 2

      Feeding game source to LLM

    3. 0

      Target Information System

    4. 2

      Feeding game source to LLM

    5. 2

      anti exp explanation pls

    6. 2

      Feeding game source to LLM

    7. 2

      anti exp explanation pls

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.