How to catch the network exception?

how to catch the network exception?

I want to detect a network outage or server temporarily closed, automatically reconnect to the server.

this is my code:

		try
		{
			Socket->Recv()
				xxxxxxxxxxx
				xxxxxxxx
				xxxxxx
				....
		}
		catch (How to write here ? What type of exception ? )
		{
		}

Maybe I need write an exception type

You’re doing your own socket calls? More than just the standard client/server?

yes,

I’m writing my own server and client,

No using UE4 server

I want to implement a distributed architecture MMORPG server,

I’m doing

Then you should ask this on StackExchange or another forum. One that is specific to what you are using. For Windows, Linux, etc, it will be at least a little different.

Thank you.

What a coincidence. I have such a technology. It clusters UE4 servers so they all work together to make one seamless space. It’s not available yet but once I have a good example game to show off, it will be.

I am looking at the source code for UE4.

I want to know how UE4 source code to catch the network exception

Then reference its code

cool…

I am re-implementing server-side with reference to “bigworld” source code

I found a way to deal with network outages,

This is my code:

		uint8 recvBuffer[1024];
		int32 read = 0;
		Connected = Socket->Recv(recvBuffer, 4, read, ESocketReceiveFlags::WaitAll);
		if (!Connected)
		{
			Socket->Close();
			ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(Socket);
			NetworkMgr->Disconnect();
			break;
		}

If can’t receive the data , disconnect and destroy the socket