Login  
Search All Forums
Dart Home | PowerTCP Winsock for ActiveX | Custom Development Reply | PowerTCP Winsock for ActiveX Topics | Forums   
AuthorForum: PowerTCP Winsock for ActiveX
Topic: TCP Client Example: Search Method Problems
jason_phs

From: Preston, United Kingdom
Posts: 2
Member Since: 08/30/06
posted October 31, 2007 12:37 PM

I am using the TCP examples to build on in order to make some test applications.

I have added to the Client sample so that it will wait until it has the complete message before processing it. The reason being, that i am sending xml as a string. Until a complete xml document is received, it will not be able to be loaded.

So on the tcp.receive event, i am using the Search method to ensure i have the end of a document before continuing. This is used on the webserver example.

heres my Receive event:

Private Sub Tcp1_Receive()
  Dim r As String
  Dim rl As Integer
  Dim Request As String
  
  Tcp1.Receive r   ' Receive the data
  rl = Tcp1.Search(r, "</message>")
  If rl > 0 Then
    Request = r
    
    Call ProcessXML(Request)
   End If
End Sub

I am searching received data for "</message>" which is the tag that marks the end of the XML string being received.
The problem is that the search method never finds "</message>" in string 'r', even though in debug, it clearly is there.

Here is an example of the XML being sent as a string:
'start message
strData = "<?xml version='1.0'?>"
strData = strData & "<message>"
strData = strData & "<msgtxt>TESTMESSAGE</msgtxt>"
strData = strData & "</message>"
'end message

The only difference i can see between this and the webserver example is that the webserver uses the client class for each session, and session_receive events.

Any help or advice appreciated.
Thanks
jason_phs

From: Preston, United Kingdom
Posts: 2
Member Since: 08/30/06
posted October 31, 2007 1:08 PM

I think i may have figured it out.
In the receieve event, i have use the receive method right before the search method.

 Tcp1.Receive r  ' Receive the data
 rl = Tcp1.Search(r, "</message>")

I guess the receive method was flushing the buffer, meaning the seach had nothing to search?

Thanks

Amit

From: Rome, NY USA
Posts: 315
Member Since: 03/15/06
posted November 1, 2007 2:22 PM

Hello,

Both Receive as well as Search methods flush the buffer. I would suggest you to please take a look at one of our sample (Blaster) which uses Search method to search for a specified token. Here is the default location of this sample:

C:\Program Files\PowerTCP\Winsock for ActiveX\Samples\Vb6\Tcp\Blaster

Best Regards,
Amit

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

Reply | PowerTCP Winsock for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX