Hi Folks,
I listed 4 items below I'm confused on?
I borrowed the network stream code from the Chit Chat Demo...
And I have tried to figure out the way to do the following but it is not happening...
1) Problem:
I need a way to look at the network stream data I receive on a characters by character or bytes by byte basis instead of looking at the buffer as a string???
See the server I'm connecting with sends out a Username: and Password: requests that I have to reply "Write" to... It also will send .png graphic files that have to be stored in cRandom binary mode but I need to find a certain flag 'PNG' and switch over to save mode...
How do I access the data and look for a U S E R N A M E : see depending on the time tick the first time I look and search the buffer as a string I could get
U S E R.... and the next tick I look at the buffer I get N A M E :.. Hence I miss the USERNAME: That is why I'd like to sift though the receive buffer on a character by character basis...
Also the system sends extra text back that is really not necessary to view I would like to sift the return and save to a file only the important info I want...
-------Start of Code Fragment----------
MY Code in SubTICK
Sub Timer1_Tick
'Stop Timer event as we are in Timer event'
timer1.Enabled = False
'Test if Data is available from Duats Server'
If client.DataAvailable = True Then
'Got Data from Duats Server reset TimeOut'
LnkToutTmr = LnkToutMax 'Decrement Link Time Out Timer
'Since Data is available
'HelpHere I really Don't understand why I cant Parse This buffer'
'bufferbits Character by Character byte by Byte...'
'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'
count = stream.ReadBytes(bufferbits(),8192)
buffer = bit.BytesToString(bufferbits(),0,count)
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
Select RcvState
'If State = 1 Look for Nam(e
Case 0
RcvState = 0
Case 1
'Since State = 1 Test if Buffer contains String name(e'
If -1 < StrIndexOf (buffer, "e:",0) Then
'Since it Does Write Access Name to Duats Sever'
txtACode.Text = AccessCode
stream.WriteBytes (stream.StringToBytes(txtACode.text & Chr(10)))
'Change State to 2 = Look For Passwor(d'
RcvState = 2
End If
------------End Code Fragment--------------
2) Problem:
I'd like to be-able to flush the Stream receive buffer etc???
3) Problem:
Could someone explain what the following items do???
'HelpHere Not Sure what this is doing but doing it'
bit.new1
'HelpHere Not sure what this does but Doing it'
client.New1
'HelpHere Not Sure what this is doing but doing it'
stream.New1(client.GetStream,False)
I listed 4 items below I'm confused on?
I borrowed the network stream code from the Chit Chat Demo...
And I have tried to figure out the way to do the following but it is not happening...
1) Problem:
I need a way to look at the network stream data I receive on a characters by character or bytes by byte basis instead of looking at the buffer as a string???
See the server I'm connecting with sends out a Username: and Password: requests that I have to reply "Write" to... It also will send .png graphic files that have to be stored in cRandom binary mode but I need to find a certain flag 'PNG' and switch over to save mode...
How do I access the data and look for a U S E R N A M E : see depending on the time tick the first time I look and search the buffer as a string I could get
U S E R.... and the next tick I look at the buffer I get N A M E :.. Hence I miss the USERNAME: That is why I'd like to sift though the receive buffer on a character by character basis...
Also the system sends extra text back that is really not necessary to view I would like to sift the return and save to a file only the important info I want...
-------Start of Code Fragment----------
MY Code in SubTICK
Sub Timer1_Tick
'Stop Timer event as we are in Timer event'
timer1.Enabled = False
'Test if Data is available from Duats Server'
If client.DataAvailable = True Then
'Got Data from Duats Server reset TimeOut'
LnkToutTmr = LnkToutMax 'Decrement Link Time Out Timer
'Since Data is available
'HelpHere I really Don't understand why I cant Parse This buffer'
'bufferbits Character by Character byte by Byte...'
'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'
count = stream.ReadBytes(bufferbits(),8192)
buffer = bit.BytesToString(bufferbits(),0,count)
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
Select RcvState
'If State = 1 Look for Nam(e
Case 0
RcvState = 0
Case 1
'Since State = 1 Test if Buffer contains String name(e'
If -1 < StrIndexOf (buffer, "e:",0) Then
'Since it Does Write Access Name to Duats Sever'
txtACode.Text = AccessCode
stream.WriteBytes (stream.StringToBytes(txtACode.text & Chr(10)))
'Change State to 2 = Look For Passwor(d'
RcvState = 2
End If
------------End Code Fragment--------------
2) Problem:
I'd like to be-able to flush the Stream receive buffer etc???
3) Problem:
Could someone explain what the following items do???
'HelpHere Not Sure what this is doing but doing it'
bit.new1
'HelpHere Not sure what this does but Doing it'
client.New1
'HelpHere Not Sure what this is doing but doing it'
stream.New1(client.GetStream,False)