Design Chat program with Winsock (turn)

Source: Internet
Author: User
Tags file transfer protocol
Summary
With the rapid development of the Internet, the communication of the network interface enables us to receive all the information that happens all over the place immediately. When we use various browser to browse various outlets, as long as the server can provide chat (chat) service items, we can through browser provided chat program and other users on the network to talk about the exchange of experience. This article designs a chat application with the Winsock control provided by Visual Basic 5.0. We can understand how the chat program works through file transfer between client and server.
Introduction to WinSock Control
Winsock is a network File Transfer protocol provided by Windows systems. When we used Winsock to design a program, we had to call the system-supplied API to do it, but invoking the API in Visual Basic is not convenient when it comes to parameter passing types. Visual Basic 5.0 provides Winsock control to simplify our design process. It can use user Datagram Protocol (UDP) or Transmission Control Protocol (TCP) to design client-server programs for your network.
TCP is a kind of connection base protocol, in the file transmission will first establish link, through link to ensure the correctness of file transfer, UDP is a kind of connectionless protocol, It does not ensure that the file on the transmission side is transferred to the receiver correctly when the file is transferred, so when we use UDP
When protocol, we usually have to do our own job of receiving confirmation.
UDP protocol seems less efficient, but it's not! The advantage of UDP protocol is that it is more efficient when the file is small, or if we want to do a network Boardcast (broadcast).
That's why! When we use the Winsock design program, first of all, according to their own needs, decided to use that kind of protocol. This article will teach you to use TCP and UDP protocol respectively to design chat programs.
Step 1: Locate domain name and IP address
In My Computer, select Control Panel. Double Click the Network option, select Identity, and you will find information such as your computer name, workgroup name, and so on. Write it down and we'll use it later.
Step 2: Designing a TCP Server program
Select New project in the File option to create a project that will see many options on the screen, such as ActiveX Document.EXE, ActiveX Document.DLL, ActiveX.EXE, ActiveXcontrol, etc. Choose Standard.EXE.
Next, select the Property Attribute option under Project, change ProjectName to tcp-server under the General option, and change the form name and caption to Server. Add a Winsock control to the form on the screen named TCPs, add two TextBox control (Outtext, Intext), and add two labels before two textbox, The caption were changed to Outtext and Intext respectively.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.