//TCP Connection Listener void ATitanBotsPlayerController::TCPConnectionListener() { //Create a socket connection to the NFC-Plugin ConnectionSocket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, TEXT("default"), false); //Remote address TSharedRef<FInternetAddr> RemoteAddress = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr(); FIPv4Address ip; FString address = TEXT("127.0.0.1"); FIPv4Address::Parse(address, ip); RemoteAddress->SetIp(ip.Value); RemoteAddress->SetPort(7000); //Connect to the 127.0.0.1 7000 Port bool Pending = ConnectionSocket->Connect(*RemoteAddress); // if we are connected to the port if (Pending) { if (ConnectionSocket != NULL) { //Global cache of current Remote Address RemoteAddressForConnection = FIPv4Endpoint(RemoteAddress); //Make limitless timer to receive FString information GetWorldTimerManager().SetTimer(Timer02, this, &ATitanBotsPlayerController::TCPSocketListener, 0.01, true); } } }
void ImportObjImpl::ResetConnection(uint16 Port) { if (Client != NULL) { Client->Close(); Client = NULL; } if (TcpListener != NULL) { TcpListener->Stop(); delete TcpListener; } UE_LOG(LogTemp, Log, TEXT("Hosting on Port %i"), Port); TcpListener = new FTcpListener(FIPv4Endpoint(IMPORTOBJ_ADDRESS, Port)); TcpListener->OnConnectionAccepted().BindRaw(this, &ImportObjImpl::HandleConnectionAccepted); }
void Fm2uPlugin::ResetConnection(uint16 Port) { if(Client != NULL) { Client->Close(); Client=NULL; } if(TcpListener != NULL) { TcpListener->Stop(); delete TcpListener; } UE_LOG(LogM2U, Log, TEXT("Hosting on Port %i"), Port); TcpListener = new FTcpListener( FIPv4Endpoint(DEFAULT_M2U_ADDRESS, Port) ); TcpListener->OnConnectionAccepted().BindRaw(this, &Fm2uPlugin::HandleConnectionAccepted); }