Home arrow Visual Basic arrow Page 7 - Two Person Chat With The Winsock Control And Visual Basic
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
TABLE OF CONTENTS:
  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
SEARCH DEVARTICLES

Two Person Chat With The Winsock Control And Visual Basic - Conclusion
(Page 7 of 7 )

One of the reasons Visual Basic is so popular is because of the way it gives us access to libraries and controls so easily. In this example, you've seen how easy it is to setup a complete chat application using the Winsock ActiveX control.

If you're interested in Winsock, then you can take our chat application and give it added functionality. Here are some ideas that you may want to try and implement:
  • Playing Sounds: Let users click a button to play a sound in the other users chat application. The easiest way to do this is to send a message such as "<< PLAY SOUND LAUGH.WAV>>" to the other computer. When that computer receives this message, it should extract the name of the file from the message (laugh.wav) and use the windows media control to play that sound.
  • Sending Files: A more difficult idea would be to allow users to swap files with each other. To do this, you'll want to break up the file and send it in chunks. You'll need to prepend the send with some sort of header block such as "<< INCOMING FILE myfile.txt >>", so that the receiving computer knows a file is on its way. Once the entire file has been sent, use a closing block to tell the receiving computer that the file send is complete.
  • Save Messages: Just like ICQ, you might want to experiment with saving messages into a users history area. You could use a flat file or a simple access database and ADO to do this. For a database, simply create three fields: messageId, message, and author. Whenever the send button is clicked, you would use an "INSERT INTO ..." command to add a new record to the database. Add a button to the chat application called history. Whenever the user clicks on it, use a "SELECT * FROM Messages WHERE author = ..." SQL query to retrieve each message in that users history.
Please take a look at some of the links and books below for more information on Winsock and network/internet programming.

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
VISUAL BASIC ARTICLES

- 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 
Support 

Developer Shed Affiliates

 




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