x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.17
Tags:
more ▼

asked Jan 13 '18 at 10:12 PM in C++ Programming

avatar image

Juvarunst
90 19 21 27

avatar image Juvarunst Jan 13 '18 at 10:19 PM

this is my code:

         try
         {
             Socket->Recv()
                 xxxxxxxxxxx
                 xxxxxxxx
                 xxxxxx
                 ....
         }
         catch (How to write here ? What type of exception ? )
         {
         }
avatar image Juvarunst Jan 13 '18 at 10:24 PM

Maybe I need write an exception type

avatar image Jin_VE Jan 13 '18 at 11:41 PM

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

avatar image Juvarunst Jan 13 '18 at 11:44 PM

yes,

I'm writing my own server and client,

No using UE4 server

avatar image Jin_VE Jan 13 '18 at 11:49 PM

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.

avatar image Juvarunst Jan 13 '18 at 11:53 PM

Thank you.

avatar image Juvarunst Jan 13 '18 at 11:55 PM

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

avatar image Juvarunst Jan 13 '18 at 11:45 PM

I want to implement a distributed architecture MMORPG server,

I'm doing

avatar image Jin_VE Jan 13 '18 at 11:53 PM

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.

avatar image Juvarunst Jan 14 '18 at 12:08 AM

cool......

avatar image Juvarunst Jan 14 '18 at 12:10 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

more ▼

answered Jan 14 '18 at 12:31 AM

avatar image

Juvarunst
90 19 21 27

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question