[Previous] [Contents] [Next]
Lesson 1:
An introduction to TCP/IP sockets and Winsock
What is a socket?
There are two types of sockets, TCP (Transmission Control Protocol) sockets and UDP (User Datagram Protocol) sockets. As you can see, these two types are called protocols. A protocol is a set of rules used to determine the way information is received and sent in a network. Other protocols are often used on top of TCP and UDP, for example, FTP is a protocol for file transfer which uses TCP to communicate with the file server. TCP and UDP themselves are built on top of the IP (Internet Protocol). The difference between these types is that in a TCP socket, the information sent is guaranteed to reach the recepient, this is not the case for UDP sockets, in this case, the information is not guaranteed to reach the recepient at all. Because of this, many UDP applications that uses datagram sockets to send information waits for the recepient to send a reply to check whether the transfer succeded or not.
To connect a socket to another computer, you need to know its IP-address and which port you are going to connect to. An IP-address consists of four numbers between 0 and 255 (although 0 and 255 are reserved) separated by dots. For example, 195.125.13.54 Each computer has 65536 different ports. Some ports are reserved for different protocols. For example, port number 80 is reserved for the HTTP (HyperText Transfer Protocol) protocol and 21 is reserved for FTP (File Transfer Protocol). All the ports under 1024 are reserved for specific protocols and should not be used by other protocols.
What do I need?
What is Winsock?
[Previous] [Contents] [Next]