Page 1 of 1

I have a question because of an error.

Posted: Sun May 15, 2022 12:27 am
by yunbg1
Hi. Antonio Linares.

I have a question because of an error.
Why am I getting this error?

test.prg

Code: Select all

//----------------------------------------------------------------------------------------
aSay := ""

DEFINE WINDOW oWnd FROM 0, 0 TO x, y TITLE "CONTROL"
        @ 1, 1 GET oSay VAR aSay MEMO OF oWnd PIXEL SIZE 260, 300
ACTIVATE WINDOW oWnd ON INIT ( SUBCLASS(oWnd:hWnd), timer(), SOCKET_OPEN() )

RETU NIL

//---------------------------------------------------------------------------
FUNC Timer()
   DEFINE TIMER oTimer INTERVAL 5000 ACTION Timer_action() OF oWnd
   ACTIVATE TIMER oTimer
RETU NIL

//---------------------------------------------------------------------------
FUNC Timer_action()

for i := 1 to 50
    cNum := subs(str(i+100, 3), 2, 2)

    socket_onoff("Send-"+cNum)

    syswait(0.2)
next

RETU NIL

//--------------------------------------------------------------------------
FUNC C_CALL(wParam)

aSay:Append( wParam, 1)

RETU NIL


//start------------------------------------------------------------------------------
#pragma BEGINDUMP

#include "windows.h"
#include "tlhelp32.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "process.h"

#include "hbapi.h"
#include "hbvm.h"

int re = 0;
SOCKADDR_IN servaddr = {0};

int my_sock;

UINT WINAPI RecvThread(void *param)
{
    char msg[128];
    SOCKADDR_IN cliaddr = {0};

    my_sock = (SOCKET)param;

    while(recv(my_sock, msg, 128, 0) > 0)
    {
       hb_vmPushSymbol( hb_dynsymSymbol( hb_dynsymFindName( "C_CALL" ) ) );
       hb_vmPushNil();
       hb_vmPushString( msg, strlen(msg) );
       hb_vmFunction( 1 );
       //printf("%s\n",msg);
    }
}

HB_FUNC(SOCKET_OPEN)
{
    WSADATA wsadata;
    WSAStartup(MAKEWORD(2,2),&wsadata);

    my_sock = socket(AF_INET, SOCK_STREAM,IPPROTO_TCP);

    if(my_sock == -1)
       hb_retnl(-1);

    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
    servaddr.sin_port = htons(5000);

    re = connect(my_sock, (struct sockaddr *)&servaddr, sizeof(servaddr));//연결 요청

    if(re == -1) {
       hb_retnl(-1);
    }

    _beginthread(RecvThread, 0, (void *)my_sock);

    hb_retni(0);
}

HB_FUNC(SOCKET_ONOFF)
{

    char message[1024] = {0x00, };
    sprintf(message, "%s", hb_parc(1));
    send(my_sock, message, sizeof(message), 0);

   hb_retnl(1);
}

HB_FUNC(SOCKET_CLOSE)
{
    closesocket(my_sock);
    WSACleanup();
}

#pragma ENDDUMP
//end-----------------------------------------------

After about an hour, the following error occurs

//error HB_OUT file

Application Internal Error - C:\test\test.exe
Terminated at: 2022.05.14 22:50:35

Unrecoverable error 9015: Symbol item expected from hb_vmDo()
Called from SYSREFRESH(0)
Called from SYSWAIT(0) in .\source\classes\FOLDER.PRG
Called from TIMER_ACTION(27) in test.prg
Called from (b)TIMER(15) in test.prg
Called from TIMEREVENT(0) in .\source\classes\TIMER.PRG
Called from (b)TWINDOW(0) in .\source\classes\WINDOW.PRG
Called from TWINDOW:TIMER(0) in .\source\classes\WINDOW.PRG
Called from TWINDOW:HANDLEEVENT(0)
Called from _FWH(0) in .\source\classes\WINDOW.PRG
Called from WINRUN(0)
Called from TWINDOW:ACTIVATE(0) in .\source\classes\WINDOW.PRG
Called from MAIN(131) in test.prg
------------------------------------------------------------------------