enet_host_create returns NULL on Windows - enet

I wrote a sample code using ENet, which was working fine under Linux but on Windows, enet_host_create returns NULL. This is a strange behavior since enet_host_create is one of the first function called while using ENet, previously any connection attempt.

enet_host_create returns NULL on Windows when you don't call enet_initialize() previously. Don't forget to call enet_deinitialize() when you're done with the library, or at the exit of your program.
A program using ENET without calling the initialize function could work on linux since this function doesn't do much on this platform. But on Windows, it will fail.
Thanks to the ENet community for their help resolving this issue.

Related

Run R.NET in and Azure Function

I am trying to integrate R into an Azure Function.
Instead of just calling the R exe - I want to be able to try the R.NET library to make it easier to pass and collect data between .NET and R. For example, respond to an event.
It runs fine locally, but once deployed as an Azure function, I get various errors. The latest ": This engine is not running. You may have forgotten to call Initialize"
For anyone else wanting to try this, I had to force the Azure function to run as 64bit, and also install the R extension library to the function. at RDotNet.REngine.CheckEngineIsRunning()
Has anyone had any success? Is anyone with R.NET experience wanting to help getting to work as an Azure function environment?
Looking at the code in R.NET for the functions RDotNet.REngine.GetInstance(), RDotNet.REngine.CheckEngineIsRunning(), and RDotNet.REngine.Initialize(), it appears as though creating the engine instance via RDotNet.REngine.GetInstance() should help you avoid this issue, as after calling that the method should be running, and you should not be encountering this area.
It is possible that you are encountering some error in creating this instance. Looking at the code comments about usage in the above link, it looks like an environment variable needs to be set for PATH. It is possible that the code you used to set this up does not work in Azure Functions. You can manually set environment variables in Azure Functions by using App Settings.

R script execution of different machines lead to different outcomes

I am new to R and I am working on a script which gets data from a REST API, processes it and saves the outcome locally on the machine. So when I execute the script on my machine it works perfectly fine but when I execute the SAME script on a different machine I get an error("missing where TRUE/FALSE needed" if that helps).
I know this is kind of a vague description of the problem but I wouldn't know what else to say besides posting the whole source code...
R, RStudio and all the packages are up-to-date. The script doesn't have any parameters.
I am looking for an explaination why the same script works on machine 1 and fails to run on machine 2.
Am I missing something R-related which might explain this strange behaviour?
I found the origin of the problem:
RStudios locale(check with sessionInfo()) differed on both machines. For some reason the unix time was given in microseconds instead of seconds. I noticed that a function argument was "NA". It seems that the numerical value of that argument was too high und resulted in "NA" which ultimatively resulted in errors.
I used Sys.setlocale("LC_ALL","English") to adjust the settings.

CL_PLATFORM_NOT_FOUND_KHR in opencl

This is a very strange situation. Why do I get error
CL_PLATFORM_NOT_FOUND_KHR
when I'm calling this function:
clGetPlatformIDs(0, NULL, &platformCount);
Earlier this error was not. I have installed the driver and SDK from Intel and Nvidia. Are there any suggestions?
Here is explained why such error can occur. clGetPlatformIDs returns CL_SUCCESS if the function is executed successfully and there are a non-zero number of platforms available. Otherwise it can return CL_PLATFORM_NOT_FOUND_KHR if the cl_khr_icd extension is enabled and no platforms are found.
You are in luck. Well sort of... Seeing this is 3 years later.
Disclaimer: I HAVE NO CLUE WHY THIS WORKS:
Machine: x64 windows 10.
Graphics Card: Geforce GTX 960
Total Failure To Load Library : LoadLibraryA( "OpenCL64.dll" )
WRONG (but loads) : LoadLibraryA( "C:/Program Files/NVIDIA Corporation/OpenCL/OpenCL64.dll" )
WRONG (but loads) : LoadLibraryA( "C:/Program Files/NVIDIA Corporation/OpenCL/OpenCL.dll" )
CORRECT: LoadLibraryA( "OpenCL.dll" )
Here is the really insideous thing: Both of my "WRONG" answers will let you
grab function pointers, but when you call clGetPlatformIDs the return status
will be 0xFFFFFC17 ( CL_PLATFORM_NOT_FOUND_KHR ).
Then you'll be examining your function call correctness.
Maybe you'll even look at the calling convention. Maybe you'll check
the header files and make sure there are not any typos there. And yet,
you are looking in all the wrong places because the original problem happened
more steps back than you think.
Because of this problem, I build into my programs code that reads a file:
"OPEN_CL_SEARCH_PATHS.TXT" so the user of the software can change what DLL file
the program attempts to load.
While I am here, I would also like to add that there seems to be a bug with the
driver that makes it so OpenCL <==> OpenGL sharing is NOT a zero-copy share and
is incredibly laggy. Now I've got to go figure out Vulkan to make my fractal
rendering engine even though OpenCL's abstraction better suits the problem.
It is probably important to note that I am NOT using an SDK or any
validation layers. In fact, I am not even using
windows.h.
I wrote assembly code to grab the address of GetProcAddress and LoadLibrary by navigating the PEB file. I am also not using cl.h or cl_platform.h.
I reconstruct the structs I need from the documentation. I am also not
bothering with prototypes for function signatures either. For example,
I call "clGetPlatformIDs" by casting it to type "F_03" and then
calling it that way.
typedef void* (F_03)( void, void*, void* );
My machine doesn't have GPU and so had to use hashcat with OpenCL for CPU alone. My machine was Intel core i3, so I have downloaded the OpenCL softwares from Intel website and installed manually and the error gone.
Source: https://youtu.be/AieYqNQ6ADM

Julia - workspace()

I've been using Win7 to develop in Julia, and I've got a method called loadAll() which runs an include(x) on all relevant files (I'm simultaneously working on a bunch of scripts and I cant be bothered to write the full path for every specific file that I update
When I try running this method using a Linux mint computer it returns the error "ERROR: invalid redefinition of constant Model", where Model is a type which I've re-written on the win7 machine
I attempted to work around this by adding workspace() (crude, I know) but it returned "ERROR: workspace not defined"
Additionally, if I exclude the script that loads the Model type (and all the other types) I get the error "ERROR: #doc not defined"
I would have posted this in the Julia forum but this seems like possibly something that might have to do with the OS rather than the Julia language itself, as I'm sure that if stuff like workspace() and #doc were malfunctioning it would already been solved
Has anybody had this experience that might understand what the problem is? Any help is greatly appreciated, as I would deeply prefer to be able to use Linux instead of windows
EDIT:
Further removing stuff, I removed all the #doc occurrences, and another error came along "ERROR: AbstractString not defined"

Is there an opencpu equivalent to browser()?

Is it possible to insert a browser statement (or equivalent) in your R code with opencpu and when the ajax or plot call is made the R session (or Rstudio session) from which the opencpu server instance is running will stop and allow debugging?
No, I don't think that would make sense. The OpenCPU server exposes an HTTP API to call R functions. If you want to debug the R function, just call it locally in R. That way you an use all your usually debugging tools.
Once the function works as expected you can call it remotely through the OpenCPU API, and it will give the same result.
Perhaps you can give an example of the type of problem that you're trying to debug, maybe I can give some advice on your workflow.

Resources