2

This is obviously a really newbie question and it might not even make sense, but lately I've been studying server and client applications the basics and have seen Socket and TCP methods. In a nutshell, what is the difference between the two methods?

1 Answers1

8

Sockets are an API (or more accurately, a library), TCP is a protocol.

Sockets are used to send data across a protocol such as UDP or TCP. Both of which run on top of IP (internet protocol).

So Sockets are what you write your program to. TCP is the language that two computers use to talk to each other over a network.

You will see some API's that have the word TCP in them or some that have UDP in them, and these are API's that specifically say to use TCP and UDP protocols. TCP are "connection oriented" while UDP are "connectionless". What this means is that TCP guarantees that packets will arrive in the correct order and will try to resend packets if they are lost of corrupted. UDP does not do those things.

So the API's that specify TCP and UDP use Sockets to create those connections.

There are also Socket API's and api's that are named starting with Tcp, like TcpListener. If that is what you are talking about, as some people seem to believe, then the Tcp classes are just higher level abstractions that wrap the low level Socket classes in order to make them easier to use.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • Thanks this was really insightful and also explained TcpListener in a nutshell along with the differences between UDP and TCP. I'm sure this will also help other newbies. – Wormhole Xd Aug 02 '13 at 23:09