Example #1
0
    # the client.
    fileData = ""

    # The temporary buffer to store the received
    # data.
    recvBuff = ""

    # The size of the incoming file
    fileSize = 0

    # The buffer containing the file size
    fileSizeBuff = ""

    # Receive the first 10 bytes indicating the
    # size of the file
    fileSizeBuff = rec_all(clientSock, 10)

    # Recive the second 10 bytes indicating file name size
fileNameSizeBuff = rec_all(clientSock, 10)  # Get the file size
fileSize = int(fileSizeBuff)

# Get the file name size
fileNameSize = int(fileNameSizeBuff)  # Recieve the file name based on size of string
fileName = rec_all(clientSock, fileNameSize);

print fileName

# Open file to write to
f = open("Copy" + fileName, 'wb')

# Get the file data
Example #2
0
    # the client.
    fileData = ""

    # The temporary buffer to store the received
    # data.
    recvBuff = ""

    # The size of the incoming file
    fileSize = 0

    # The buffer containing the file size
    fileSizeBuff = ""

    # Receive the first 10 bytes indicating the
    # size of the file
    fileSizeBuff = rec_all(clientSock, 10)

    # Recive the second 10 bytes indicating file name size
fileNameSizeBuff = rec_all(clientSock, 10)  # Get the file size
fileSize = int(fileSizeBuff)

# Get the file name size
fileNameSize = int(
    fileNameSizeBuff)  # Recieve the file name based on size of string
fileName = rec_all(clientSock, fileNameSize)

print fileName

# Open file to write to
f = open("Copy" + fileName, 'wb')
Example #3
0
while True:
    command = raw_input("ftp>")

    if len(command.split()) == 1:
        if command.split()[0] == "LIST":
            _list(connSock)
        elif command.split()[0] == "QUIT":
            break
        else:
            print "Incorrect Command"
    elif len(command.split()) == 2:
        if command.split()[0] == "GET":
            _get(connSock)

            # Get the length of the ephemeral port number
            len_eport_num = rec_all(connSock, 10)

            # Get the actual ephemeral port number
            eport_num = rec_all(connSock, len_eport_num)

            esocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

            esocket.connect(server_address, int(eport_num))

            file_size_buff = rec_all(esocket, 10)

            file_size = int(file_size_buff)

            f = open(command.split()[1], 'wb')

            file_data = rec_all(eport_num, file_size)
Example #4
0
while True:
    command = raw_input("ftp>")

    if len(command.split()) == 1:
        if command.split()[0] == "LIST":
            _list(connSock)
        elif command.split()[0] == "QUIT":
            break
        else:
            print "Incorrect Command"
    elif len(command.split()) == 2:
        if command.split()[0] == "GET":
            _get(connSock)

            # Get the length of the ephemeral port number
            len_eport_num = rec_all(connSock,10)

            # Get the actual ephemeral port number
            eport_num = rec_all(connSock, len_eport_num)

            esocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

            esocket.connect(server_address, int(eport_num))

            file_size_buff = rec_all(esocket, 10)

            file_size = int(file_size_buff)

            f = open(command.split()[1], 'wb')

            file_data = rec_all(eport_num, file_size)