How to use the Winsock ActiveX control with Visual FoxPro


The FoxSock.exe sample is adapted from the first Microsoft Visual Basic sample presented in the article "Using the Winsock Control", which is available at the following MSDN Web site: The Microsoft Winsock Control ships with Visual FoxPro (VFP) 6.0 and later. It is not supported in VFP 5.0. This sample has been tested on Microsoft Windows 98, Microsoft Windows 2000, and Microsoft Windows XP.

More Information

The following file is available for download from the Microsoft Download Center:
Download Download the FoxSock.exe package now.Release Date: February 22, 2002

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to obtain Microsoft support files from online services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
The FoxSock.exe file contains the following files:

File nameSize

To use this sample, follow these steps:
  1. Unzip FoxSock.exe to your computer, and then set the default directory in Visual FoxPro to the directory to which you extracted the files.
  2. Run Winsock.prg to launch the server and client forms.
  3. Click Connect on the client form, and type some text in the Send text box in either form. When you leave the Send box, your text will appear in the other form's Receive box.
Differences from the Visual Basic sample include the following:

  • You need to use the ".Object" syntax when you call the Winsock control's methods (for instance, oleWinsock.Object.Connect) instead of referring to the control directly from the OleControl.
  • The control setup code is placed in the Init method instead of the Load method. The Visual Basic example does not close the connection. If you close the forms in VFP without closing the connection first, VFP appears to stop responding (hang) for a while.
  • Additional settings (Close buttons, tab order) were made for clarity.

ID articol: 315124 - Ultima examinare: 6 aug. 2008 - Revizie: 1