Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> An Indepth Look At The Winsock Control, Part I - The Basics
ghostrider
post Nov 15 2006, 11:07 PM
Post #1


Super Member
*********

Group: Members
Posts: 397
Joined: 9-June 06
From: Wisconsin
Member No.: 24,924



I wrote this just today. Please tell me if its written well. If you guys like it I'll continue you to write more.

An Indepth Look at the Winsock Control
Part I - The Basics

Who This Documentation Is For:
This documentation on the Winsock control is for any Visual Basic programmer that wants to learn about communication between two or more computers. Communication between computers was something I found fun to learn, and also teachs many other key concepts like string parsing and control arrays. I recommend that you have some expierence with Visual Basic, enough that you are able to handle variables and know what the functions Chr(), Asc(), Mid(), and other common functions do. You should also know the difference between functions and subs, and how to return the result from a function. You should also understand how variables work. I will add comments on any code that might not make sense.

What is covered in Part I:
In Part I, I will go over the two different protocols (ways that data is sent and how the connections are set up), what IP addresses are, and what ports are. No actual code is written in this part, however by the end we will have made a fully useable chat application that is capable of chat between 2 or more than 2 different people.

The Two Different Protocols:
Using the Winsock control there are two different protocols, or two different ways of connecting to another computer and sending data. They are named Transfer Control Protocol (TCP), which is the default protocol if you do not define one. The other much less used protocol is called User Datagram Protocol (UDP). There are many technical differences between TCP and UDP, but they do not affect us. The difference that is important that we need to concern ourselves with is this, TCP requires a connection between, and UDP does NOT.

How TCP connects to computers:
In a TCP connection, one computer is the server. The server 'listens' for incoming requests, and then either 'accepts' them or closes the connection. The client(s) 'connect' to the server. In order for you to make the connection, the client(s) need to know either the host name or IP address of the server, and the port that the server is listening on. TCP is very much like a telephone, the client(s) call the server, and the server picks up the phone. After the connection has been established, both computers can send data back and forth.

How UDP works:
Very unlike TCP, UDP does not need a connection. UDP does not have a server or a client. Each computer needs to know the port the computer is transfering data through, and the IP address of the other. UDP is suitable for sending small amounts of data between computers. UDP is like passing a note in class, no connection is needed like a telephone.

What are IP Addresses and Ports:
An IP address is like the address of your house. Each person has a different one, and it identifies you. An IP address has a format like this xxx.xxx.xxx.xxx. Not all of the x's have to be used in each set of x's. The 4 x sets can be from the values of 0 to 255. IP addresses within Local Area Networks always start with 192.xxx.xxx.xxx or 172.xxx.xxx.xxx or even 10.xxx.xxx.xxx. It is important that you understand that computers can have more than one IP address. For example right now, my computer has two, one of them being the one that it has inside of my local area network (the network I have in my house) and one for the internet, that other computers outside of my LAN know my computer as.
Each computer 65536 ports, number from 0 to 65535. Ports were designed so that data doesnt come through all at once, it can be seperated. HTTP (Hypertext Transfer Protocol) or more commonly know as web pages uses Port 80, and FTP (File Transfer Protocol) uses port 21. These ARE NOT different protocols that the Winsock control usees. Don't get confused by that. HTTP and FTP both happen to work using TCP.

This post has been edited by ghostrider: Nov 16 2006, 12:07 AM
Go to the top of the page
 
+Quote Post
jlhaslip
post Nov 15 2006, 11:19 PM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,880
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



Nice work. Keep it coming.
You have a very nice approach to simplifying the material of a complex topic. I look forward to seeing more information from you on this issue. And why, exactly is it in Quote tags?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Birth Control Recommendations?(9)
  2. Illegal Immigration And Border Control(21)
  3. Making A Song In Fruity Loops Part Three(1)
  4. A Small Social Networking Site....(9)
  5. Are You Part Of The 2% Or The 98%?(18)
  6. Runescape 2 Private Server Guide: Part 1(16)
  7. Transfer File Of Any Size Using Winsock Control(5)
  8. You Control What Happens In Your Dream..?(22)
  9. Ftp Account Management(1)
  10. Winbinder Listview Control?(0)
  11. How To Acess Domain Control Panel.help Needed(5)
  12. How To Control Other Users’ Privileges (microsoft Windows Steadystate 2.5)(1)
  13. Sleep Control(15)
  14. Getting Rid Of That Little Pot Belly(0)
  15. Runescape 2 Private Server Guide: Part 2(19)
  1. Do You Believe In Astrology?(19)
  2. Connecting Two Computers With A Crossover Cable(7)
  3. Remote Control A Computer With Sound(2)
  4. Your Winning Eleven(6)
  5. Bill Bailey's Part Troll... What Is That Thing?(0)
  6. Microsoft Publisher(7)
  7. Incredible Rising Gas Prices(15)
  8. A Adsl Router With A Control Panel And A Log(4)
  9. Diabetes And Insulin Pump Therapy(4)
  10. Dog Care Basics(9)
  11. Writing An Essay - Part I: Sentences(6)
  12. Java Part 1(2)
  13. Make A Song In Fruity Loops Final Part(2)
  14. Cpanel Preinstalled Scripts, Extras, And Cpanel Options(1)
  15. Gaining Total Control(0)


 



- Lo-Fi Version Time is now: 25th July 2008 - 10:29 AM