Пример #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)
Пример #2
0
    'quality_points': 224,
    'gpa_hours': 65,
    'gpa': 3.446154
})

checkFor = []

while 1:
    RTP.acceptRTPSocketConnection(snew, incoming)
    if RTP.isConnected(snew):
        thread = threading.Thread(target=listenForServerRequests)
        thread.start()
        threads.append(thread)
    #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)
Пример #3
0
    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
        MESSAGE = studentData[a]
        ####s.send(MESSAGE)