B4J Question I need to configure a communication as a Socket Server for IPC Linux Socket for local app communication

ThorstenStueker

Member
Licensed User
I can't find a solution to do in B4J but I also can# t beleeve that it will be impossible. Is there a way to communicate with normal IPC Sockets with B4J or not? I qould be happy if someone would have a helping answer.
 

ThorstenStueker

Member
Licensed User
Thanks Erel, I already (cause I am not passioned enough) implemented for this case a TCP Server Socket and communication works correct. I had the Problem that I have to define a file instead of an adress for this IPC communication. Thats not UDP....but okay, I found my solution, thank you much.
 
Upvote 0

ThorstenStueker

Member
Licensed User
Here is the Solution wich communicates (without the rest, only the communications Part):


B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Private zeitmaschine As Timer

Private halserver As ServerSocket
Private halstream As AsyncStreams

    
    Private a As Int =0
End Sub

Sub AppStart (Args() As String)

        zeitmaschine.Initialize("zeitmaschine",2300)
    zeitmaschine.Enabled=True
    halserver.Initialize(51042, "Halserver")
    halserver.Listen
    
    StartMessageLoop
    End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub


Sub zeitmaschine_tick
    a=a+1
    Log(a)
If halserver.IsInitialized=True Then Log("is init")

'halstream.Write("received!".GetBytes("utf8"))
End Sub

Sub halserver_NewConnection (Successful As Boolean, NewSocket As Socket)
    Log("New connection")
    If Successful Then
        
        
        
        
        
        halstream.Initialize(NewSocket.InputStream, NewSocket.OutputStream, "halstream")
    End If
    halserver.Listen
    Log ("Hal is listening")
    
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…