Understanding the intricacies of how computers interact is an important part of networking and is of equal interest to a sysadmin as well as to a developer. In this article, we will make an attempt to discuss the concept of communication from the very basic fundamental level that needs to be understood by everybody. Communications between computers on a network is done through protocol suits. A protocol suit consists of a layered architecture where each layer depicts some functionality which can be carried out by a protocol. Each layer usually has more than one protocol options to carry out the responsibility that the layer adheres to.
Build a TCP/UDP Client and Server to Send and Receive Packets
C program for file Transfer using UDP - GeeksforGeeks
A TCP transmission control protocol is a connection-oriented communication. It is an intermediate layer of the application layer and internet protocol layer in the OSI model. TCP is designed to send the data packets over the network. It ensures that data is delivered to the correct destination. TCP creates a connection between the source and destination node before transmitting the data and keeps the connection alive until the communication is active. In TCP before sending the data it breaks the large data into smaller packets and cares the integrity of the data at the time of reassembling at the destination node.
File Transfer FTP Using TCP | source code in C Network Programming
Both TCP and UDP have a point to point architecture, and it uses sockets for client to communicate with the server and vice-versa. When it comes to understanding socket programming, there are two socket types for two transport services:. An application example would be the below code.
OK then that is simply a matter of defining your data protocol such that it passes file name information when sending a data file. Your actual data transmission will then take your requirements into consideration. For example, when you send a file, you first write 4 bytes to the stream which represent the length of the file path INTEGER data type , then write the characters of the file path to the stream, then you send 8 bytes which represent the length of the data file LONG data type , and finally you write the file data itself.