def main(url):

    parsed = urlparse(url)
    # exit on unsupported application protocol
    if parsed.scheme.lower() != 'http':
        print '"' + parsed.scheme  + '"' + ' scheme address is not supported'
        sys.exit()
    host = parsed.netloc
    filename = getFilename(parsed.path)
    request = getRequest(parsed.path, host)
    print filename
    print request
    # Initiate the download
    startTime = time.time()
    sock = TCP()
    sock.connect(host)
    sock.sendGet(request)

    # Start the retrieve
    filedata = sock.transmission()
    	
    print filedata

    # if found it is a non-200 packet, exit
    if not filedata.startswith("HTTP/1.1 200"):
        print ('Non-200 HTTP status code is not supported')
    	sys.exit(0)

    # remove the HTTP header:
    pos = filedata.find("\r\n\r\n")
    if pos > -1:
        pos += 4
        filedata = filedata[pos:]

    endTime = time.time()

    # save file to disk
    saveFile(filename, filedata)
    print len(filedata),
    print 'Bytes received'
    #timecost = '%.2g' % (endTime - startTime)
    #print timecost,
    #print 'seconds passed. Average speed:',
    #throughput = '%f' % (len(filedata) / float(timecost) / 1000)
    #print throughput,
    #print 'KBps'
    sock.sock.close()