myftp.c - File myftp.c Author Aung Myin 32812965 Pan Xu 32813676 Description This is the main implementation file for the myftp client

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

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

/* * File: myftp.c * Author: Aung Myin 32812965 & Pan Xu 32813676 * * Description: This is the main implementation file for the myftp client * program. */ #include <arpa/inet.h> #include <netdb.h> // Provides hostent #include <netinet/in.h> // Provides sockaddr_in, htons(), htonl(), etc. #include <stdio.h> // Standard I/O #include <stdlib.h> #include <string.h> #include <sys/socket.h> // Provides sockets, gethostbyname(), etc. #include <sys/types.h> #include <unistd.h> #include "service.h" #define LOCALHOST 3232236030 //192.168.1.254 #define SERV_PORT 40058 // My port number /* * Function: addrTypeCheck * Returns: int - 0 if IP address, 1 if hostname * Parameters: char * - string containing IP address or hostname * * Use: This is just a quick check to figure out if the parameter provided * as a command line argument is an IP address or a hostname. */ int addrTypeCheck(char *address) { int i = 0; int strLength = strlen(address); for (i = 0; i < strLength; ++i) { if ((address[i] < 48) || (address[i] > 57)) { if (address[i] != 46) { return (1); } } } return (0); } int main(int argc, char *argv[]) { char hostname[100]; struct sockaddr_in servAddr; struct in_addr netIP; // Used to convert input string to IP struct hostent *servInfo; // Used to get IP from hostname
Image of page 1
Image of page 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture