Why is the error "FSocket is not a type name" occurring?

I’ve been trying to figure out why I’m getting an error on my FSocket declarations… I’ve included all the headers. Another error that is coming up is the Socket.h seems to have tons of errors. Here is my code, and thanks for your help!

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

#pragma once
#include "NervewalkFramework.h"
#include "Runtime/Networking/Public/Networking.h"
#include "Runtime/Networking/Public/Interfaces/IPv4/IPv4Endpoint.h"
#include "Runtime/Networking/Public/Interfaces/IPv4/IPv4Address.h"
//#include "Runtime/Sockets/Public/IPAddress.h"
#include "NervewalkPlayerController.h"
#include "Runtime/Sockets/Public/Sockets.h"
#include "Runtime/Sockets/Public/SocketSubsystem.h"
#include <string>
class NERVEWALKFRAMEWORK_API NervewalkNetworking : public FRunnable

	static NervewalkNetworking* Runnable;
	FRunnableThread* Thread;
	ANervewalkPlayerController* ThePC;
	FThreadSafeCounter StopTaskCounter;
	FSocket* ListenerSocket;
	FSocket* ConnectionSocket;
	FIPv4Endpoint RemoteAddressForConnection;
	std::string data;

	NervewalkNetworking(ANervewalkPlayerController* IN_PC);
	void Launch();
	//FRunnable interface
	virtual bool init();
	virtual uint32 Run();
	virtual void Stop();
	//End FRunnable Interface
	void EnsureCompletion();

	bool StartTCPReceiver(const FString& SocketName, const FString& IP, const int32 port);

	//take a look at the last parameter..
	FSocket* CreateTCPConnectionListener(const FString& SocketName, const FString& IP, const int32 port, const int32 ReceiveBufferSize = 2 * 1024 * 1024);

	//Timer functions (consider turning into threads)
	void TCPConnectionListener();
	void TCPSocketListener();

	//Format String IP4 to number array (no idea what this means..)
	bool FormatIP4ToNumber(const FString& IP, uint8(&Out)[4]);

	//Converts Binary to String
	FString BinaryConversion(const TArray<uint8>& BinaryArray);
	std::string stringData(FString fstringData);
	//makes sure only one thread is going on
	static NervewalkNetworking* JoyInit(ANervewalkPlayerController* IN_PC);
	static void Shutdown();
	static bool IsThreadFinished();
	bool IsFinished();


Hi aegle,

The reason that you’re having issues including Sockets.h is because it is not part of the Engine API. If you navigate to the Sockets.h file, you can see the API by looking at the class declaration:

class SOCKETS_API FSocket

If you wish to include files such as this that aren’t part of the Engine API, you have to add them to your list of dependencies in the Build.cs file for your project. You can add it on this line:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore"});

Have a nice day,

Thanks for answering, but I already had Sockets and Networking to my list of dependencies in the build.cs file. I still have no clue why this issue persists.

The same issue occurs, however the project compiles.

Does this issue persist if you try this in a fresh project? Try only adding the dependency, the include statement, and the variable declaration. Also, can you try using this to include Sockets.h instead?

#include "Sockets.h"

Not sure if this will help in diagnosing the error but I made a gist of the list of errors. https://gist.github.com/arushirai1/850dbd8368c4912ffed9
(this is from the original project)

These seem like they are all IntelliSense warnings, not actual compiler errors. IntelliSense is known to give a lot of false positives when it comes to types that are being included from other folders in large projects due to it not finishing parsing, which is most likely the case here as you are including multiple modules. Can you give me the output from the output log (Not the error list) for when you’re unable to compile in your original project?

I believe you’re correct, it seems like all of these errors are pointing toward issues with the way you’re code is put together. I don’t see any mention of ISocketSubsystem in that list of outputs however. Could you post this error message if it persists?

Ah I see. The output is above^

After looking at the output log, I believe there aren’t errors with FSocket, rather the way I implemented it. Am I right?

Though I’m not sure why there are errors on ISocketSubsystem… Thanks for your help! :smiley:

On line 17 of the gist.

1>(132): error C2653: ‘IOSocketSubsystem’ : is not a class or namespace name

Nevermind got it, it was a typo.