FSocketSubsystemSteam::GetHostByName not implemented, returns code 21?!

Hi!

I’m trying to resolve a host name via

ResolveInfo = ISocketSubsystem::Get()->GetHostByName("irc.twitch.tv");

Problem is, when I’m running my game with Steam integration, it uses the FSocketSubsystemSteam implementation, which doesn’t have this implemented and returns only SE_EADDRNOTAVAIL? Is there a reason for this or am I screwed? Can I just copy the implementation from elsewhere?

Using 4.7.

Thanks!

Hi Anteevy,

You’ll want to use the PLATFORM_SOCKETSUBSYSTEM macro in your Get() call to tell the system to use the platform default instead of the OnlineSubsystem default.

Your call should look like this:
ResolveInfo = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->GetHostByName("irc.twitch.tv");

Hope that helps!

Hey! That sounds exactly like what I need, but somehow it still doesn’t work and still uses the Steam implementation. Currently debugging this - calling GetSocketAPIName() on the socket subsystem I get with ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM) returns “WinSock”, which sounds right. But in the end it jumps into the Steam implementation (put a log there). I feel like I’m missing something…

So FResolveInfoAsync::DoWork() calls ISocketSubsystem::Get() without the parameter and afterwards calls GetHostByName from the Steam subsystem. Can’t I somehow set the Windows subsystem as the default one, instead of the Steam one?

I think I have solved this. Now calling the other GetHostByName() function that is not async, but works well enough.

ISocketSubsystem* SocketSubSystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
TSharedRef<FInternetAddr> Addr = SocketSubSystem->CreateInternetAddr(0, 0);
ESocketErrors SocketError = SocketSubSystem->GetHostByName("irc.twitch.tv", *Addr);

This actually uses the platform’s SocketSubSystem and not the Steam one.

Looks to me like FResolveInfoAsync::DoWork() is intended to call into your own subsystem, at which point you can redirect to the PLATFORM_SOCKETSUBSYSTEM for example. I don’t think you’ll be able to use it out of the box with the steam subsystem for the reasons you describe.

edit: I wonder if this has been fixed in the steam socket subsystem since 2016. In UE 4.25 SocketSubsystemSteam::GetAddressInfo will fall back to PLATFORM_SOCKETSUBSYSTEM if the address doesn’t look like a steam ID.