UE5 C++的TCP服务器与客户端

 客户端.h

需要在Build.cs中加入模块:"Networking","Sockets","Json","JsonUtilities"

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ClientActorClass.generated.h"

UCLASS()
class TCPSERVERANDCLIENT_API AClientActorClass : public AActor
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
	AClientActorClass();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	static FSocket* Socket;

	//"Networking","Sockets"
	UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
	static bool ClientConnectToTCPServer(const FString& IP,int32 Port = 8888);

	UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
	static bool SendDataFormClicentToServer(TArray<uint8> SendData);

	UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
	static bool DisConnectFormClientToServer();

	UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
	static TArray<uint8> ReceiveDataFromTCPServer();

	//"Json","JsonUtilities"
	UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
	static void StringToBytes(FString InString,bool& OutBool,TArray<uint8>& OutBytesArray);

	UFUNCTION(BlueprintCallable,Category = "TCPServerAndClient")
	static void DataTypeToJSON(int32 Int,bool Inbool,F

相关推荐

  1. UE5 C++TCP服务器客户

    2024-01-17 21:00:05       33 阅读
  2. esp32服务器android客户tcp通讯

    2024-01-17 21:00:05       35 阅读
  3. Python中TCP服务器客户简易实现

    2024-01-17 21:00:05       11 阅读
  4. C++ TCP 服务客户通信例子

    2024-01-17 21:00:05       12 阅读
  5. C++客户服务器TCP创建

    2024-01-17 21:00:05       30 阅读
  6. 【Python】OPC UA 服务器客户实现

    2024-01-17 21:00:05       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-17 21:00:05       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-17 21:00:05       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-17 21:00:05       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-17 21:00:05       18 阅读

热门阅读

  1. 复试 || 就业day15(2024.01.13)算法篇

    2024-01-17 21:00:05       35 阅读
  2. 笨蛋学设计模式结构型模式-装饰者模式【9】

    2024-01-17 21:00:05       33 阅读
  3. 力扣209-长度最小的子数组

    2024-01-17 21:00:05       39 阅读
  4. ZZULIOJ 1125: 上三角矩阵的判断

    2024-01-17 21:00:05       29 阅读
  5. 什么是去中心化

    2024-01-17 21:00:05       33 阅读
  6. Nginx配置ssl访问 443端口

    2024-01-17 21:00:05       32 阅读
  7. 力扣124. 二叉树中的最大路径和

    2024-01-17 21:00:05       31 阅读
  8. C++——STL标准模板库——容器详解——set

    2024-01-17 21:00:05       29 阅读
  9. 笔记本装FreeBSD机器磁盘一直响的解决留档

    2024-01-17 21:00:05       53 阅读
  10. 127.0.0.1和0.0.0.0的区别

    2024-01-17 21:00:05       32 阅读