pc=55500 s.bind((host,pc)) addressserver=(host,ps) terminate="start" check,add=s.recvfrom(10) print check while terminate!="exit": if check=='s': fileName=raw_input("Enter file name :") f=open(fileName,'rb') package.send(f,s,addressserver) elif check=='r': f=open('rserver','wb') package.recfile(f,s,addressserver) print "You wnat to send = s or receive = r or for exit = exit" check=raw_input() if check=='r': s.sendto("s",addressserver) elif check=='s': s.sendto("r",addressserver) elif check=='exit': s.sendto("exit",addressserver) s.close()
import socket import package import os s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) host = socket.gethostname() ps = 55000 pc = 55500 s.bind((host, pc)) addressserver = (host, ps) foldername = raw_input("Enter folder name") dirlist = os.listdir(foldername) dirlen = len(dirlist) s.sendto(str(dirlen), (host, ps)) #os.chdir('./'+foldername) os.chdir(foldername) i = 1 j = 0 while (dirlen >= i): s.sendto(dirlist[j], (host, ps)) f = open(dirlist[j], 'rb') package.send(f, s, addressserver, str(dirlist[j])) i = i + 1 j = j + 1 s.close()
host = socket.gethostname() ps = 55000 pc = 55500 s.bind((host, pc)) addressserver = (host, ps) terminate = "start" check, add = s.recvfrom(10) print check while terminate != "exit": if check == 's': fileName = raw_input("Enter file name :") f = open(fileName, 'rb') package.send(f, s, addressserver, fileName) elif check == 'r': f = open('rserver', 'wb') package.recfile(f, s, addressserver) print "You wnat to send = s or receive = r or for exit = exit" check = raw_input() if check == 'r': s.sendto("s", addressserver) elif check == 's': s.sendto("r", addressserver) elif check == 'exit': terminate = "exit" s.sendto("exit", addressserver) s.close()
host = socket.gethostname() ps = 55000 pc = 55500 s.bind((host, ps)) addressclient = (host, pc) terminate = "sdf" print 'you want to send = s and receive = r' check = raw_input() if check == 'r': s.sendto('s', (host, pc)) else: s.sendto('r', (addressclient)) while terminate != "exit": if check == 'r': f = open('rfile', 'wb') package.recfile(f, s, addressclient) elif check == 's': fileName = raw_input("Enter file name :") f = open(fileName, 'rb') package.send(f, s, addressclient, fileName) check, add = s.recvfrom(10) if check == 'exit': terminate = "exit" s.close()