I'm reading the source code of godot , and I can't understand how NetSocket class creates its instance.
In net_socket.cpp , create() is defined, but I can't see how it works.
#include "net_socket.h"
NetSocket *(*NetSocket::_create)() = NULL;
NetSocket *NetSocket::create() {
if (_create)
return _create();
ERR_PRINT("Unable to create network socket, platform not supported");
return NULL;
}
Especially, what is _create
? And what does NetSocket *(*NetSocket::_create)() = NULL;
do actually?
You're looking at the wrong file. That one just delegates to whatever platform-specific implementation has been linked in/instantiated, using a function pointer called _create
.
It is set in, for example, the POSIX impl .
Simply search the codebase for instances of _create
and you'll see how it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.