i am use Private server As ServerSocket Private astream As AsyncStreams, but when connect other client disconect el first cliente
B4X:
Sub Process_Globals
Private server As ServerSocket
Private astream As AsyncStreams
End Sub
Sub AppStart (Args() As String)
server.Initialize(51042, "server")
server.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 server_NewConnection (Successful As Boolean, NewSocket As Socket)
Log("New connection")
If Successful Then
astream.
astream.Initialize(NewSocket.InputStream, NewSocket.OutputStream, "astream")
End If
server.Listen
End Sub
Sub astream_NewData (Buffer() As Byte)
Log(BytesToString(Buffer, 0, Buffer.Length, "utf8"))
astream.Write("received!".GetBytes("utf8"))
End Sub
Last edited: