B4J Question How to send Text messages after connection

pythonds1

New Member
I want to send text message from client to server and server to client.I know about
AsyncStreams but i don't know how to implement . Can anyone tell me how to send text messages from client to server ?

Server code

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

Sub AppStart (Args() As String)
    server.Initialize(5478,"server")
    server.Listen
    StartMessageLoop   
End Sub

Sub server_NewConnection (Successful As Boolean, NewSocket As Socket)
    Log("Connection Created")   
    server.Listen
End Sub


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

Sub Process_Globals
    Private Socket As Socket

End Sub

Sub AppStart (Args() As String)
    Socket.Initialize("Socket1")
    Socket.Connect("192.16.1.100" ,5478,20000)
    StartMessageLoop
End Sub


Sub Socket1_Connected (Successful As Boolean)
    If Socket.Connected = True Then
        Log("Connected........")
    End If
 
End Sub
 
Top