Page 90 - Python Cơ Bản
P. 90

import socket



           s = socket.socket()

           host = socket.gethostname()

           port = 12345

           s.bind((host, port))



           s.listen(5)

           while True:

              c, addr = s.accept()

              print 'Got connection from', addr

              c.send('Thank you for connecting')

              c.close()





          ɇSϰR GSHI XVɱR OLM XLрG XLM WЌ GLϰ] Zɧ PϾRK RKLI Ю TSVX


          8'4        1ЦM OLM Gɹ QШX OЎX RРM Xк GPMIRX WЌ LMЖR VE



          XLɺRK FɨS OЎX RРM Xк -4 Zɧ 4SVX RɧS  Zɴ Hд   Got connection

          from Got connection from ('192.168.1.104', 60018)



          7EY чɹ  KЮM XVϲ QШX QIWWEKI ZЪM RШM HYRK  Thank you for
          connecting  ZА GLS GPMIRX  7EY чɹ  чɹRK OЎX RРM ZЪM GPMIRX




                'PMIRX WMHI
   85   86   87   88   89   90   91   92