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?
-
http://stackoverflow.com/questions/11981106/tcpclient-vs-socket-when-dealing-with-asynchronousy – MethodMan Aug 02 '13 at 20:52
-
@DJKRAZE you misunderstand his question. He's not asking about a Listener vs a socket. – Erik Funkenbusch Aug 02 '13 at 20:53
-
Perhaps you could show which "methods" you mean? As it stands your question is vague and doesn't really make sense. – spender Aug 02 '13 at 20:55
-
@spender - I don't think he means "methods" as in functions. I think he means methods as in "ways of doing things". – Erik Funkenbusch Aug 02 '13 at 20:57
1 Answers
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.

- 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