Click here to Skip to main content
15,886,530 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please explain for me, what is protocol of TCP packet ?
If I want to use that to make the client-server program for chat between 2 computers ( application connect with socket)
Posted

Protocol is named TCP, Transmission Control Protocol, see for more detail: http://en.wikipedia.org/wiki/Transmission_Control_Protocol[^].

It will work for your chat application. To get some ideas, look at my past answers.

This is a skeleton design of server with threads serving multiple remote sockets:
Multple clients from same port Number[^].

You can use TCP on several different levels, see:
how i can send byte[] to other pc[^],
Communication b/w two Windows applications on LAN.[^].

With v.2.0, you can use them all up to classical remoting, inclusively. That is, WCF is not available, you would need v.3.5 or 4.0. For your task probably the most suitable approach is the one based on TcpListener/TcpClient.

—SA
 
Share this answer
 
v3
Comments
Abhinav S 26-Jun-11 0:14am    
Good answer. My 5.
Sergey Alexandrovich Kryukov 26-Jun-11 0:42am    
Thank you, Abhinav.
--SA
Vivek Krishnamurthy 26-Jun-11 1:21am    
My 5!
Sergey Alexandrovich Kryukov 26-Jun-11 1:36am    
Thank you, Vivek.
--SA
thatraja 26-Jun-11 1:37am    
Fine answer, 5!
You need not worry about the underlying working of TCP too much if you are using socket programming.

For an overview on the TCP protocol start here[^].
Afterwards, you can look at TCP/IP Chat Application Using C#[^] for an actual implementation of a chat program using TCP.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Jun-11 0:09am    
Agree with you, my 5.
I also provided useful information, please see my answer.
--SA
Abhinav S 26-Jun-11 0:14am    
Thank you.
thatraja 26-Jun-11 1:38am    
That article already in my bookmarks, 5!
Abhinav S 26-Jun-11 1:40am    
Thanks.
TCP is a stream protocol. You will need to split the stream up into messages. Two common ways to do that for textual data are to insert particular bytes as delimiters, or prepend each message with its length.

You do not need to know about the packet level protocol, TCP implementations hide that from you – from a programming point of view a TCP connection is a stream (well, an input and and output stream).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900