Summary

Team Fly 

Page 317

 
        txtResponse.AppendText(data & vbCrLf)
        data = RStream.ReadLine
    End While
    wResp.Close()
End Sub

Reading lines off the incoming stream synchronously is not a very efficient process either. The Stream object exposes the BeginRead/BeginWrite and EndRead/EndWrite methods, which are very similar to the asynchronous methods of the WebResponse object: they accept a delegate and they invoke it when the read/write operation has completed. You can edit the code of the application and make the read operations asynchronous as well.

Summary

The .NET Framework was designed from the ground up with the Internet in mind. It provides numerous tools that simplify the communication between remote systems, including the all-new Web services. In addition to the new ways of harnessing the Internet, the .NET Framework includes the basic classes that expose the traditional functionality of sockets.

In this chapter you've learned the basics of the Socket class, as well as how to use specific classes to exchange data with the TCP and UDP protocols. These classes are the TCPListener, TCPClient, and UDPClient classes and they abstract the basic operations you'd have to perform with traditional sockets to move data between two computers using the TCP and UDP protocols, respectively. The TCP protocol requires a dedicated connection, and each computer engaged in the conversation has a distinct role, either as a client or as a server. The UDP protocol is connectionless, and the computers involved in the conversation are all clients.

You've also learned how to use the WebClient, WebRequest, and WebResponse classes to interact with web resources from within your code. The WebClient class is the simplest one; it allows you to exchange data with a web server in a synchronous mode. The other two classes provide asynchronous methods, which enable you to write functional and responsive interfaces that interact with remote resources.

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net