The Microsoft Visual Basic Winsock Control

Chapter 14

The Microsoft Visual Basic Winsock Control

This chapter describes the Visual Basic Winsock control, whose purpose is to simplify the Winsock interface into an easy-to-use interface natively available from Visual Basic. Before the control was available, the only option for Winsock network programming from Visual Basic was to import all of the Winsock functions from the DLL and redefine the many necessary structures. This process was extremely time-consuming and prone to numerous errors, such as mismatching the type declarations. However, if you need the extra flexibility offered by directly importing Winsock into Visual Basic, take a look at the Visual Basic examples that are available in Chapter 1. Each example contains a file, WINSOCK.BAS, which imports the necessary constants and functions. With the release of .NET Application Frameworks version 1 and Visual Studio .NET, there is a new, much more flexible Winsock interface called .NET Sockets, which we described in Chapter 13. It is capable of supporting most of the Winsock functionality from a Visual Basic application in an efficient managed environment. We highly recommend that Visual Basic applications start using the new .NET Sockets interface for all Winsock programming tasks. However, this chapter focuses only on the Visual Basic Winsock control. We'll first cover the properties and methods of the control and then present several examples that use it.

The first Winsock control was introduced with Visual Basic 5. A revised version of the control became available with the release of Visual Studio Service Pack 2. Visual Basic 6 includes the latest version of the Winsock control. The various version differences are discussed toward the end of this chapter.

The Winsock control provides only a basic interface to the Winsock APIs. Unlike Winsock, which is a protocol-independent interface, the Winsock control can use only the IPv4 transport. In addition, it is based on the Winsock 1.1 specification. The control supports both TCP and UDP, but in a rather limited sense. The control itself is not able to access any socket options, which means that features such as multicasting and broadcasting aren't available. Basically, the Winsock control is useful only if you require basic data networking capabilities. It does not provide the best performance because it buffers data within the control before it passes it to the system, thus adding a bit of overhead and uncertainty.



Network Programming for Microsoft Windows
Network Programming for Microsoft Windows (Microsoft Professional Series)
ISBN: 0735605602
EAN: 2147483647
Year: 2001
Pages: 172
Authors: Anthony Jones

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