HaxeFoundation / HaxeFoundation/hxcpp
obtaining socket fd throws `Invalid Socket Handle`
- Dominant language
- C++
- Stars
- 330
- Forks
- 227
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 18
Description
```
inValue.mPtr = 0x0
```
```haxe
var socket = new sys.net.Socket();
fd(socket.__s);
```
```haxe
@:native("SOCKET_FD")
extern public static function fd(socket: Socket): Int;
```
```haxe
@:headerCode("
int SOCKET_FD(Dynamic socket);
")
@:cppFileCode("
#include
#include
#define APPNAME \"MyApp\"
typedef int SOCKET;
static int socketType = 0;
struct SocketWrapper : public hx::Object
{
HX_IS_INSTANCE_OF enum { _hx_ClassId = hx::clsIdSocket };
SOCKET socket;
int __GetType() const { return socketType; }
};
SOCKET val_sock(Dynamic inValue)
{
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, \"inValue.mPtr = %p\", inValue.mPtr);
if (inValue.mPtr)
{
int type = inValue->__GetType();
if (type==vtClass)
{
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, \"type is vtClass\");
inValue = inValue->__Field( HX_CSTRING(\"__s\"), hx::paccNever );
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, \"inValue.mPtr = %p\", inValue.mPtr);
if (inValue.mPtr==0)
return 0;
type = inValue->__GetType();
}
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, \"type = %d\", type);
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, \"socketType = %d\", socketType);
if (type==socketType)
return static_cast(inValue.mPtr)->socket;
}
hx::Throw(HX_CSTRING(\"Invalid socket handle\"));
return 0;
}
int SOCKET_FD(Dynamic socket) {
return val_sock(socket);
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.