Home arrow Visual Basic arrow Page 2 - Two Person Chat With The Winsock Control And Visual Basic

Two Person Chat With The Winsock Control And Visual Basic

The Microsoft WinSock library allows you to connect to a remote machine and exchange data using either the User Datagram Protocol (UDP) or the Transmission Control Protocol (TCP). Both protocols can be used to create client-server applications. In this tutorial Jason will be teaching you how to create a direct-connect chat program that uses TCP. The program itself will be designed in such a way that it can act as both the client and server.

Author Info:
By: Jason Brimblecombe
Rating: 5 stars5 stars5 stars5 stars5 stars / 320
January 12, 2002
  1. · Two Person Chat With The Winsock Control And Visual Basic
  2. · Creating the chat form
  3. · Code from the clients point of view
  4. · Code from the clients point of view (contd.)
  5. · Code from the servers point of view
  6. · Using our chat application
  7. · Conclusion

print this article

Two Person Chat With The Winsock Control And Visual Basic - Creating the chat form
(Page 2 of 7 )

Start by loading Visual Basic and creating a new standard exe application. Rename form1 to frmMain. To allow our chat application to communicate over the Internet, we need access to the Microsoft Winsock library. We can access this library in two ways. Firstly, by adding a reference to the library from the Project -> References menu option. Secondly, we can add the Microsoft Winsock ActiveX component into our application. The second way allows us to easily create an instantiation of the Winsock library in the form of a control, so we will use this method.

Click on the Projects menu, and then the Components menu item. Scroll down the list of available components and check the "Microsoft Winsock Control 6.0" option:

Selecting the Winsock library as a component

Click Apply and then the OK button. We've just made the Winsock ActiveX control available to our application. The Winsock control is now part of the controls toolbar and is represented like this:

The Winsock control

Now that we have access to the Winsock library, let's create the layout and controls that make up our chat form. In the Visual Basic form designer, our chat form looks like this:

Our chat application in Visual Basic

Basically, our chat form is composed of one image, four text boxes and four buttons. The details of each of these controls are shown below:

Each control and its descriptions

Don't worry too much about the design and layout of the chat form. The complete source code and a compiled version of the chat application are included with the support material for this article, which is available from the last page.

I will concentrate on describing the most important methods of our application from here on in.
blog comments powered by Disqus

- Developing an XML Web Service Using Visual S...
- Creating an HTML File List with VB
- Fun with Email: VB6, CDO, MAPI, and a Remote...
- Extranet/Intranet Dictionary Cracker in VB
- Finding Default App Icons With Visual Basic
- Registry Fever With Visual Basic
- Implementing An ADO Data Control With VB6
- Printing With Visual Basic
- MSMQ Part 1/2: Architecture and Simple Imple...
- Magnifying The Desktop With Visual Basic
- Sending Email With MAPI Components in Visual...
- Two Person Chat With The Winsock Control And...
- A Real-Time ActiveX News Control
- Accessing the Windows API in Visual Basic

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials