Socket Application

Bachrock

Member
Licensed User
Longtime User
Greetings,

I have an application using the Network Example (Socket Connections). I have process flow meters feeding into a PC. I want to feed that data to a tablet over a socket connection. I have it working for a 1 time only situation. Meaning when I make the connection, I can send the flow data to the tablet and actually get the correct reading on the tablet. (Pretty Cool!) What I would like to do is keep the connection open and stream the data to the tablet and display the data on the screen real time.

Does anyone have any examples or direction in which you can point me in to get me started?

Any example code would be greatly appreciated.

Thanks :sign0104:
 

Bachrock

Member
Licensed User
Longtime User
Continuing on

Ok since posting my original post last night I was able to make some headway using the asyncstreamstext example. Below is the code as I have it right now. Everything is working except when I send the string from my visual basic program it goes immediately to Sub ast_Terminated. I have tried adding CRLF to the end of my string in VB as well as just CR. I added the asyncstreamstext.bas module into my program. Seems like it should work but i am missing one little thing. :sign0085::BangHead:



Sub Process_Globals

Private ast As AsyncSteamsText
Private server As ServerSocket

End Sub

Sub Globals
Dim EditText1 As EditText
End Sub


Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
server.Initialize(5500, "server")
Log(server.GetMyWifiIP)
server.Listen
End If
EditText1.Initialize("EditText1")
EditText1.ForceDoneButton = True
Activity.AddView(EditText1, 10dip, 10dip, 300dip, 60dip)
End Sub

Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
EditText1.Text = "Connected"
If ast.IsInitialized Then ast.Close
ast.Initialize(Me, "ast", NewSocket.InputStream, NewSocket.OutputStream) 'initialize AsyncStreamsText with the socket streams.

End If

server.Listen
End Sub


Sub ast_NewText(Text As String)

Log("Text: " & Text)
Log(Text.Length)
EditText1.Text = Text

End Sub

Sub ast_Terminated
EditText1.text = "Failed"
Log("Connection terminated")
End Sub
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Neat, I need to do a similar thing.

What did you mean you added the module to your program?

Maybe that's the step I'm missing.
 
Top