Download

C++ Server Code vs Client Code

So when you build out your executables (sever and client) does the client executable contain the dedicated server’s executable code? I know this is probably a complex answer but I am just curious how this works.

UFUNCTION(reliable, server, WithValidation)
void ServerSetSomeBool(bool bNewSomeBool);
virtual void ServerSetSomeBool_Implementation(bool bNewSomeBool);
virtual bool ServerSetSomeBool_Validate(bool bNewSomeBool);

Basically what I am asking is will the client contain code for _Implementation and _Validate?

I have been looking around and cant seem to find the answer I am looking for… I have seen some people mention using #IF preprocessor macros but they were posts from early 2014… I just want to make sure I am implementing correctly.

Curious to hear the answer to this myself.

I’d like to bump this, because the answer to this/how to do this would be nice.

Thanks for bumping. I didnt want to seem impatient. I really want to know as well :stuck_out_tongue:

If I’m not wrong, it makes sense that the client does contain this code because it can be a listen server (and execute said code), right?

I’d be curious too if it gets included by default.

To be on a safe side, if you really want to exclude code from Client, wrap it with:



#if UE_SERVER
//...code
#endif


Yes its included if explicitly not defined with #if statement, otherwise the listen server would not work as stated by Snowcrash5.

Yeah, Clients will contain the Server code unless you wrap it with the preprocessor blocks. If you want to exclude code, that’s the only way.

Thanks for the info. It makes sense to use the preprocessor blocks. I just wasn’t sure if there was a way to do without. Not hard to add them in though :wink:

It probably is on client as well, but unless you have some serious security issues it shouldn’t be much of problem. The RPC call will always be routed back to the server, and only server implementation will be called in any case.