DataAvailable event never fires in Consoleapp

MainIPCSocketClass(Super:IPCSocket)
IPCArray(Global Array, type:MainIPCSocketClass)

With above configuration, I’m able to create several ConsoleApps by running shells.
In Connected event(MainIPCSocketClass), I can also get ACK message from slave consoleapps.

However, when I try to send a message to those slaves, DataAvailable event of slave consoleapps(CollectorIPCSocket, Super:IPCSocket) never fire.
I’m using below code in Main app.

IPCArray(0).Write “COMMAND” + EndOfLine
IPCArray(1).Write “COMMAND” + EndOfLine

Can you tell me how I can trace it? Is there something wrong?

Are you running an event loop in the console app? Desktop apps provide an event loop for you, console apps do not. You need to call app.DoEvents in your console app (in a loop) to activate events.

Yes, I do. When I pass ‘START’ argument through shell, this slave sends the ‘IAMREADY’ message to Main well.
However, when Main tries to send a message to slave through IPCSocket, DataAvailable event of the slave doesn’t fire.
That’s the problem.

  While not bFinished
    
    App.DoEvents
    
    If StopOrStartBoolean Then 'START
      
      theIPCSocket = New CollectorIPCSocket
      
      If repInstanceCountPassed = "0" Then
        theIPCSocket.Path = SpecialFolder.Temporary.Child("com.example.ipcsocketexample").NativePath + str(0)
      ElseIf repInstanceCountPassed = "1" Then
        theIPCSocket.Path = SpecialFolder.Temporary.Child("com.example.ipcsocketexample").NativePath + str(1)
      Else
        logging("Unknown repInstanceCountPassed" )
      End If
      
      theIPCSocket.Connect
      theIPCSocket.Write EndOfLine + "IAMREADY from StreamGroup : " + repStreamGPassed + " InstanceCount : " + repInstanceCountPassed  + EndOfLine
      
    Else 'STOP/False
      
      exit While
      
    End If
  Wend
  
  Quit(exitReason)

Your loop seems strange. You either create a socket or exit immediately. Shouldn’t there be a third option - the “normal” running state?

Yes…
I found out that as soon as Main got the “IAMREADY” message from the slave, Main got socket error 102 ( lost connection ).

I will try to put Socket logic out of App.DoEvents.

Thanks for you point.
App.DoEvents logic was wrong. Now it seems to work… Thank you!

  dim repTimer as new getRepIntervalTimer
  repTimer.mode = Timer.ModeMultiple
  repTimer.Period = 10000
  
  theIPCSocket = New CollectorIPCSocket
  
  If repInstanceCountPassed = "0" Then
    theIPCSocket.Path = SpecialFolder.Temporary.Child("com.example.ipcsocketexample").NativePath + str(0)
  ElseIf repInstanceCountPassed = "1" Then
    theIPCSocket.Path = SpecialFolder.Temporary.Child("com.example.ipcsocketexample").NativePath + str(1)
  Else
    logging("Unknown repInstanceCountPassed" )
  End If
  
  theIPCSocket.Connect
  theIPCSocket.Write EndOfLine + "IAMREADY from StreamGroup : " + repStreamGPassed + " InstanceCount : " + repInstanceCountPassed  + EndOfLine
  Logging("repCollector " + str(repStreamGPassed) + " Sending IAMREADY message to Main Application ")
  
  Do
    App.DoEvents
  Loop