Esempio n. 1
0
def listenForServerRequests():
    print "Listening for server requests!"
    while (True):
        data = RTP.receiveData(snew)
        #if "GET" in str(request):
        #    print "GETTING a file"
        #    request = str(request).replace("GET: ", "")
        #    print "Getting file: ", request

        #with open (request, "r") as myfile:
        #    data = myfile.read()

        RTP.sendData(snew, data)
Esempio n. 2
0
    #conn, addr = s.accept()

    data = RTP.receiveData()
    #data = conn.recv(BUFFER_SIZE)

    if not data:
        here = 'await data'
    else:
        messageBack = "This ID does not exist"
        for w in range(0, len(students)):
            if (data == students[w]['ID']):
                messageBack = "ID EXISTS"
                IDINDEX = w
                break
        ######conn.send(messageBack)  # echo
        RTP.sendData(snew, messageBack)
        if messageBack == 'ID EXISTS':
            ####lstLength = conn.recv(BUFFER_SIZE)
            lstLength = RTP.receiveData()
            ####conn.send("Taking Fields")

            RTP.sendData(snew, "Taking Fields")
            errorMsg = ''
            # create list of asked for fields
            for a in range(0, int(lstLength)):
                ####data = conn.recv(BUFFER_SIZE)
                data = RTP.receiveData()
                if (data not in students[w]):
                    errorMsg = data + ": This field does not exist"
                    checkFor = []
                    ####conn.send(errorMsg)
Esempio n. 3
0
# checking if data to search was given
if len(sys.argv) < 4:
    print "No data was asked for"
    sys.exit()

# putting the fields asked for into a list
x = 3
while x < len(sys.argv):
    studentData.append(sys.argv[x])
    x = x + 1

MESSAGE = studentID

# connection established and ready to send ID to check if it exists
####s.send(MESSAGE)
RTP.sendData(snew, MESSAGE)
####data = s.recv(BUFFER_SIZE)
data = RTP.receiveData()

# check if ID is present
if data != "ID EXISTS":
    print "This ID does not exist"
    sys.exit()
else:
    # send length of list asked for
    ####s.send(str(len(studentData)))
    RTP.sendData(snew, str(len(studentData)))
    # receives "Taking Fields"
    ####data = s.recv(BUFFER_SIZE)
    data = RTP.receiveData()
    for a in range(0, len(studentData)):  # Send over Fields