Connect and send data between programs (Part 3) : send file (text, pdf, multimedia)

Python to Python (python3.4)

Code ฝั่ง SERVER
Code ฝั่ง Client


Errorที่พบ :
เกิดจากการที่server กับ client ไม่สามารถติดต่อถึงกันได้ อาจเป็นเพราะหาportไม่พบ
แก้โดยตั้งหมายเลขportให้เท่ากัน


ไม่ทราบสาเหตุ
แก้ไขโดยการเปลี่ยน Version Python จาก 3.4 > 2.7



Socket API
socket.socket()  สร้าง Socket
socket.gethostname() ดึง host name ของเครื่องมาใช้
.bind((host, port))  ผูก Socket กับ address เข้าด้วยกัน
.accept()  ตอบรับการเข้าถึงของ client
.send() ส่งข้อความไปหาserver หรือclient
.close() ปิดการทำงาน




ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

Connect and send data between programs (Part 1) : Send data by Socket

Connect and send data between programs (Part 4) : Send large file + MD5 Checksum

Connect and send data between programs (Part 2) : Send data using Thai language