I want to receive mac address of the clients as soon as they connect to server. For this I have tried sockets but server won't run unless I set a timeout. I want to run sockets the entire time so that I can receive data from client whenever it reaches server. Basically I have a wi-fi setup and want to keep record of clients using their mac address who are connecting to my wi-fi network. Is there any other way to get their mac address apart from ssh. my view.py file is as follows, if there is error please notify.
from django.shortcuts import render
import os
# Create your views here.
#from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
#import socket, sys
import pickle
import socket
TCP_IP = '127.0.0.1'
TCP_PORT = 5005
BUFFER_SIZE = 1024
s = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
s.bind((TCP_IP, TCP_PORT))
s.listen(1)
s.settimeout(3)
try:
conn, addr = s.accept()
objrcv = pickle.loads ( conn.recv ( 1024 ) )
ip = objrcv[0]
mac = objrcv[1]
except:
print "Can't connect"
def student_detail(request):
queryset = attendance.objects.filter(mac=mac)
context ={
"object_list":queryset,
"title": "Attendance",
}
return render(request, "attendance.html", context)