myftpd.c - File myftpd.c Author Aung Myin 32812965 Pan Xu 32813676 Description This is the main file for the myftpd server program The myftpd server is

myftpd.c - File myftpd.c Author Aung Myin 32812965 Pan Xu...

This preview shows page 1 - 2 out of 2 pages.

/* * File: myftpd.c * Author: Aung Myin 32812965 & Pan Xu 32813676 * * Description: This is the main file for the myftpd server program. The myftpd * server is used to provide a simple file transfer protocol as * defined in the ProtocolSpecification file. */ #include <errno.h> // Provides error code macros and errno #include <netinet/in.h> // Provides sockaddr_in, htons(), htonl(), etc. #include <stdio.h> // Standard I/O, perror(), misc. stuff #include <string.h> // String functions, memset() #include <sys/socket.h> // Socket stuff #include <sys/types.h> // Provides pid_t and other data types #include <unistd.h> // Provides fork(), read(), write(), etc. #include "daemon.h" // My daemon functionality #include "service.h" // Provides a service to the client #define SERV_PORT 40058 #define BUF_SIZE 512 int main(int argc, char *argv[]) { int sock0, sock0con, cliAddrLength; struct sockaddr_in servAddr, cliAddr; pid_t pid; // Set up initial 'working directory' if (argc == 1) { printf("No directory specified. Using current\n"); } else if (argc == 2) { if (chdir(argv[1]) < 0) { printf("Directory not valid. Exiting...\n"); exit(1); } else {
Image of page 1
Image of page 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture