windows - C++ TCP Socket Plugin -


i working simulation engine vbs2 , attempting write tcp socket plugin. have client application want connect plugin , send single message. perhaps make more sense if post existing plugin code:

#include <windows.h> #include "vbsplugin.h"  // command function declaration typedef int (winapi * executecommandtype)(const char *command, char *result, int resultlength);  // command function definition executecommandtype executecommand = null;  // function register executecommand function of engine vbsplugin_export void winapi registercommandfnc(void *executecommandfnc) {   executecommand = (executecommandtype)executecommandfnc; }  // function executed every simulation step (every frame) , took part     in simulation procedure. // can sure in function executecommand registering done. // deltat time in seconds since last simulation step vbsplugin_export void winapi onsimulationstep(float deltat) {   //{ sample code: executecommand("0 setovercast 1", null, 0);   //!} }  // function executed every time script in engine calls script function "pluginfunction" // can sure in function executecommand registering done. // note plugin takes responsibility allocating , deleting returned string vbsplugin_export const char* winapi pluginfunction(const char *input) {   //{ sample code:   static const char result[]="[1.0, 3.75]";   return result;   //!} }  // dllmain bool winapi dllmain(hinstance hdll, dword fdwreason, lpvoid lpvreserved) {    switch(fdwreason)    {       case dll_process_attach:          outputdebugstring("called dllmain dll_process_attach\n");          break;       case dll_process_detach:          outputdebugstring("called dllmain dll_process_detach\n");      break;       case dll_thread_attach:          outputdebugstring("called dllmain dll_thread_attach\n");          break;       case dll_thread_detach:          outputdebugstring("called dllmain dll_thread_detach\n");          break;    }    return true; } 

the message sent plugin used in onsimulationstep() function being passed argument executecommand(). however, i've got careful blocking here onsimulationstep() function must allowed run every simulation step.

i've been staring @ few days , have tried looking @ winsock tutorials, i'm not c++ programmer , feeling rather stuck. please kind enough give me few pointers in right direction?

thanks in advance, advice appreciated.

i go boost::asio save myself hassle in dealing asynchronous io.

it relatively straightforward use, , works in plugin environment - i've done similar (also in vbs2).


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -