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"

Why does UE4 always miss the first packet?


I press a button, and it sends a packet, containing a string data "Hello" to my server.

My C# server receives it, and then sends it back to the client (UE4).

My UE4 doesn't get the packet.

         TArray<uint8> ReceivedData;
         uint32 Size;
         while (mySocket->HasPendingData(Size))
             ReceivedData.SetNumUninitialized(FMath::Min(Size, 65507u));
             int32 Read = 0;
             mySocket->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);
         if (ReceivedData.Num() <= 0)
             FString temp = TEXT("False");
             return temp;

I press the button the second time,

Server gets it, and now client gets it. And so on.

Why does the client miss the first one?

It's bad, because if my players type in the correct password and username the first time, the server will say that's right, but the client will not receive, until the player presses the button the second time.

Thank you.

Product Version: UE 4.9
more ▼

asked Mar 21 '16 at 10:33 PM in C++ Programming

avatar image

219 19 18 25

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

1 answer: sort voted first

Hi! How exactly do you invoke this code? I think problem in that you don't wait when data come from server, so I mean following:

  1. When you press button in first time you send date on the server and invoke the code for receiving. But server may be ( if we take into account ping) not catch you message and not done responce, when you try receive one.

  2. while (mySocket->HasPendingData(Size)) this code only check that the socket has any pending data on the queue and how I think the socket hasn't pending data yet.

  3. When you press button again socket already have data and you handled them successfully.

So I advice for you try check socket several times in timer. But it not so good solution if you would like use socket many times. It this way I suggest use more general solution like this: https://wiki.unrealengine.com/TCP_Socket_Listener,_Receive_Binary_Data_From_an_IP/Port_Into_UE4,_(Full_Code_Sample)

P.S. Hi from broly... ;-)

more ▼

answered Mar 23 '16 at 05:18 AM

avatar image

53 6 8 9

avatar image Moynzy Mar 24 '16 at 06:11 PM

Yo, Yogi bear.

So from Ramas link, I set a timer, that listens for packets.

Funny thing is, it works when I host server on PC, and client on Same PC.

If I play from different IP I miss packets. It's TCP!

(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