Jump to content

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
https://metin2.dev/topic/16195-small-fix-about-connect/
Share on other sites

  • 6 months later...
  • Honorable Member
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
https://metin2.dev/topic/16195-small-fix-about-connect/#findComment-96809
Share on other sites

  • 2 years later...

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.