# Android - Crash with TCP Code

**URL:** <https://forums.unrealengine.com/t/android-crash-with-tcp-code/262136>\
**Category:** Mobile\
**Tags:** unreal-engine, Android\
**Created:** [November 22, 2021, 1:07pm UTC](https://forums.unrealengine.com/t/android-crash-with-tcp-code/262136 "2021-11-22T13:07:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_00a422be](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_00a422be](https://forums.unrealengine.com/u/anonymous_user_00a422be)\
**Post date:** [November 22, 2021, 1:07pm UTC](https://forums.unrealengine.com/t/android-crash-with-tcp-code/262136/1 "2021-11-22T13:07:24Z")

</div>

It took me almost a month to run my project as an Android application.  
It runs well as a Window program. Although the Android package was successful, the app crashed with start-up.

After a lot of trial and error, I realized that the TCP plugin(that I bought in Market) was the problem, and implemented the TCP function as a C++ class.  
The same thing happened even though I wrote TCP in C++.  
When I delayed the TCP transmission execution time by using TiCK function, Crashwas delayed using the TICK function, the time at which the app crashes is also delayed.

I’d appreciate it if you could let me know what I’m missing.

Below is my code.

```auto
#include "MyActor.h"
#include "Networking.h"
#include "Sockets.h"
#include "SocketSubsystem.h"
#include "IPAddress.h"
// Sets default values

AMyActor::AMyActor()
{
	nCount = 0;
	PrimaryActorTick.bCanEverTick = true;
}

void AMyActor::SendSomething()
{

	AsyncTask(ENamedThreads::GameThread, []()
		{

			ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);

			FSocket* Socket = FTcpSocketBuilder(TEXT("Android Porting Test"));
			FIPv4Endpoint Endpoint(FIPv4Address( ***,*** , ***,*** ), 9999);

			if (Socket->Connect(*Endpoint.ToInternetAddr()))
			{
				//success
			}
			else
			{
				return;
			}

			char* buff = (char*)"Test2222";
			int32 sendSize = 0;
			Socket->Send((uint8*)buff, strlen(buff), sendSize);
			// Code placed here will run in the game thread 

	});
}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if (nCount == 10)
		SendSomething();
	else
		nCount++;
}

```

- UE Version : 4.26

---

<div class="post-metadata">

**Author:** ![harshGoda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/harshgoda/32/484177_2.png) [@harshGoda](https://forums.unrealengine.com/u/harshGoda)\
**Post date:** [November 25, 2021, 12:16pm UTC](https://forums.unrealengine.com/t/android-crash-with-tcp-code/262136/2 "2021-11-25T12:16:26Z")

</div>

check for the Internet permission in your project

---

<div class="post-metadata">

**Author:** ![harshGoda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/harshgoda/32/484177_2.png) [@harshGoda](https://forums.unrealengine.com/u/harshGoda)\
**Post date:** [November 25, 2021, 12:16pm UTC](https://forums.unrealengine.com/t/android-crash-with-tcp-code/262136/3 "2021-11-25T12:16:45Z")

</div>

if still it arise send the logs here
