def start_com(self): s_is = Scanner(self.s.getInputStream()) file_name = s_is.nextLine() print(file_name) pro = Runtime.getRuntime().exec(file_name) try: pro_os = PrintStream(pro.getOutputStream()) except: pass print("reached") try: f = open(raw_input("Enter input file name: "), "r") lp = [] print(str(f) + " file") for k in f: lp.append(str(k)) for k in lp: pro_os.print(k) except: pass finally: pro_os.close() pro_is = Scanner(pro.getInputStream()) s_os = PrintStream(self.s.getOutputStream()) s_os.println(file_name + " recieved") while pro_is.hasNext(): s_os.println(pro_is.nextLine()) s_is.close() s_os.close() self.s.close()
def client_run(self): cl_is = Scanner(self.s.getInputStream()) cl_os = PS(self.s.getOutputStream()) cl_os.println(self.Sc.nextLine()) print(cl_is.nextLine()) print(cl_is.nextLine()) while True: cl_os.println(self.Sc.nextLine()) print(cl_is.nextLine())
def run(self): st_os = PrintStream(self.so.getOutputStream()) st_os.println(self.li) print ("writting complete") st_is = Scanner(self.so.getInputStream()) while st_is.hasNext(): print (st_is.nextLine()) st_os.close() st_is.close() self.so.close()
def run(self): print("broad time...") if len(self.reg_obj_ip) > reg.i: reg.i += 5 for k in self.reg_obj_ip: if k.isConnected() and not (k.isClosed()): K = PrintStream(k.getOutputStream()) K.println("BroadCast Message....") else: self.reg_obj_ip.remove(k) else: print("here") Thread.sleep(5000)
class multi_client(Thread): def __init__(self, s): self.s = s self.cs_IS = None self.cs_OS = None def run(self): self.cs_IS = Scanner(self.s.getInputStream()) self.cs_OS = PrintStream(self.s.getOutputStream()) self.cs_OS.println("breaches are open...") x = self.cs_IS.nextLine() self.cs_OS.println(x + " server received") while True: x = self.cs_IS.nextLine() self.cs_OS.println(x + " server received")
from java.net import Socket as SO from java.io import InputStream from java.io import OutputStream from java.io import PrintStream as PS from java.util import Scanner as S from java.io import File SO_1 = SO("127.0.0.1", 777) IS_1 = S(SO_1.getInputStream()) OS_1 = PS(SO_1.getOutputStream()) S1 = S(File("input.txt")) while True: if S1.hasNext(): OS_1.println(S1.next()) print(IS_1.next()) else: break
from java.net import ServerSocket as SS from java.net import Socket as SO from java.io import InputStream from java.io import OutputStream from java.io import PrintStream as PS from java.util import Scanner as S SS_1 = SS(777) SO_1 = SS_1.accept() IS_1 = S(SO_1.getInputStream()) OS_1 = PS(SO_1.getOutputStream()) while True: if IS_1.hasNext(): print(IS_1.next()) print(OS_1.println("received...")) else: break