HMBatch as server

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hi all,

 

I wanted to launch hypermesh as a server and my client will send various requests to the server.

 

***********************************************************************************************************************************

SERVER CODE : HM_Server.tcl

 

set LogFile [open C:/temp/tcl_out.txt w]

 

proc Server {channel clientaddr clientport} {

global LogFile

puts $LogFile 'Hello'

}

 

set chanID [socket -server Server 30000]

puts $chanID

 

***********************************************************************************************************************************

 

I'm launching the hmopengl.exe using ShellExecuteEx method.

 

***********************************************************************************************************************************

CLIENT CODE

 

//Format the command line parameter to be passed for HM in batch mode

TCHAR* cmdLineParam = TEXT('-tcl C:/HM/Tcl_Scripts/HM_Server.tcl');

 

//Execute the hypermesh in batch mode and wait for it to complete

HINSTANCE hInst = 0;

SHELLEXECUTEINFO ShExecInfo = {0};

ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);

ShExecInfo.fMask = SEE_MASK_DEFAULT;

ShExecInfo.hwnd = GetSafeHwnd();

ShExecInfo.lpVerb = TEXT('Open');

ShExecInfo.lpFile = TEXT('C:\\Program Files\\Altair\\12.0\\hm\\bin\\win64\\hmopengl.exe');        

ShExecInfo.lpParameters = cmdLineParam;   

ShExecInfo.lpDirectory = NULL;

ShExecInfo.nShow = SW_SHOWNORMAL;

ShExecInfo.hInstApp = hInst; 

ShellExecuteEx(&ShExecInfo);

 

 

***********************************************************************************************************************************

The above code is working fine with hmopengl.exe

where as it is not working with hmbatch.exe [ ShExecInfo.lpFile = TEXT('C:\\Program Files\\Altair\\12.0\\hm\\bin\\win64\\hmbatch.exe') ];

I could not find the issue...

Tagged:

Answers

  • tinh
    tinh Altair Community Member
    edited October 2015

    Hi

    I do not ever use hmbatch. but i guess perhaps it use tcl shell (not wish app like in hm), you may need vwait to enter event loop

    anyway, I see your client invoked server code, why?

     

    client should access server via socket $serverIP 30000

     

    and if you already test on hm before, the port may not be used again by hmbatch server. Using free port is recommended

    and don't forget flushing channel

     

    If you are communicating between different hypermesh session on one pc, you can use dde facility, it is more simple than socket

     

    image/emoticons/default_smile.png' alt=':)' srcset='/emoticons/smile@2x.png 2x' width='20' height='20'>

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2015

    Hi 

    the Port 30000 is free one. Because I'm able to use that port with hmopengl.exe and it is being closed properly. But sill as you said, I'll try to make use of the free port.

    Even I tried to use vwait but I dont see the function 'Server' is called at all while making the connection from the client.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2015

    I'm curious to know how you work in 'client-server' mode.

  • tinh
    tinh Altair Community Member
    edited October 2015

    do you flush the channel???

     

    forexample

     

    #client code

     

    set chan [socket $ServerIP 30000]

    puts $chan 'Hello, this is client'

    flush $chan; #now server can get greeting and reply

     

     

    Remember than: set chanID [socket -server Server 30000] , this chanID is not used to communicated to client, you have to remember client channel within 'Server' procedure.

     

    But you can use it to retrieve IP: set IP [fconfigure $chanID -sockname]

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited October 2015

    Hi all,

     

    I wanted to launch hypermesh as a server and my client will send various requests to the server.

     

    ********************************************************************************************************

    SERVER CODE : HM_Server.tcl

     

    ....

    If you like to do that, why need write ... your server with TCL?

    At your place, I'll use a web server, like Apache, with PHP/Perl. A simple web form to send data and at server just run the job.

  • tinh
    tinh Altair Community Member
    edited October 2015

    I think babu_rect wants to do some simple tasks by tcl because it's embedded into hw