Data can be transferred between two computers using Socket programming in C.
Similarly, files can easily be sent using UDP protocol and a simple client/server.
Security : Handled by encryption.
Protocol : UDP
Encryption: XOR encryption
Algorithm :
1. The server starts and waits for filename. 2. The client sends a filename. 3. The server receives filename. If file is present, server starts reading file and continues to send a buffer filled with file contents encrypted until file-end is reached. 4. End is marked by EOF. 5. File is received as buffers until EOF is received. Then it is decrypted. 6. If Not present, a file not found is sent.
The Server :
// server code for UDP socket programming #include <arpa/inet.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #define IP_PROTOCOL 0 #define PORT_NO 15050 #define NET_BUF_SIZE 32 #define cipherKey 'S' #define sendrecvflag 0 #define nofile "File Not Found!" // funtion to clear buffer void clearBuf( char * b) { int i; for (i = 0; i < NET_BUF_SIZE; i++) b[i] = ' |