Sockets/Network

drenwick

New Member
Licensed User
Longtime User
Hi there,
please can you help out with a problem with the socket class. I can't seem to get it to actually send any data.
Connection to the remote server is all OK, but I never receive any data fro my device.
Code included here.
Any suggestions welcomed.

Thanks

dave


Variables are defined in Process_Globals as follows;

Dim RemoteConnector As Socket
Dim RemoteOutputStream As OutputStream


In Activity_Create is initialize the socket as follows;

RemoteConnector.Initialize("RemoteConnector")
RemoteConnector.Connect("192.168.1.125", 1088, 10 * 1000)


My Connected Event is called with Successful = True;

Sub RemoteConnector_Connected(Successful As Boolean)
Log("RemoteConnector_Connected: START")
If Successful Then
Log(TAB & "Connection successful")
RemoteOutputStream = RemoteConnector.OutputStream
RemoteWrite("Some Data here")
Else
Log(TAB & "Connection Un-successful")
End If

End Sub


And I attempt to write data to the remote server using;

Sub RemoteWrite(Message As String)
Dim WriteBuffer(0) As Byte
WriteBuffer = Message.GetBytes("UTF8")
RemoteOutputStream.InitializeToBytesArray(WriteBuffer.Length)
If RemoteOutputStream.IsInitialized Then
Log("IsInitialized = True")
Else
Log("IsInitialized = False")
End If

RemoteOutputStream.WriteBytes(WriteBuffer, 0, WriteBuffer.Length)
RemoteOutputStream.Flush
End Sub
 
Top