Hi,
I need to communicate between my IOS add and a B4J server using the least amount of bytes: this is why I'm using sockets instead of HTTP requests.
This is what my server has (A B4J console app with StartMessageLoop):
This is what the IOS app has:
The connection is being made Succesfully, but I can't seem to get into the astreams_NewData of the server, whatever I try. What am I missing ?
I need to communicate between my IOS add and a B4J server using the least amount of bytes: this is why I'm using sockets instead of HTTP requests.
This is what my server has (A B4J console app with StartMessageLoop):
B4X:
private Sub ListenForSocketConnections
socketsrvr.Initialize(1973, "serversocket")
socketsrvr.Listen
Wait for serversocket_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
If astreams.IsInitialized Then
astreams.Close
End If
astreams.InitializePrefix(NewSocket.InputStream, True, NewSocket.OutputStream, "astreams")
End If
End Sub
private Sub astreams_NewData (Buffer() As Byte)
End Sub
This is what the IOS app has:
B4X:
Dim sck As Socket
sck.Initialize("socket")
sck.Connect("192.168.1.59", 1973, 0)
wait for socket_Connected (Successful As Boolean)
If Successful Then
astreams.InitializePrefix(sck.InputStream, True, sck.OutputStream, "astreams")
Dim dt As DataTransfert
dt.Initialize
Dim data() As Byte = dt.UploadDataToByteArray(id, latitude, longitude, GetBatteryLevel)
astreams.Write(data)
End If
The connection is being made Succesfully, but I can't seem to get into the astreams_NewData of the server, whatever I try. What am I missing ?