开发者

How to implement server & multi-clients "communication"?

What I aim to do is to fulfill a mutual communication between one server but multiple clients. Here is the Server part I wrote:

Import subprocess, time, socket, fileinput
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host=''
port = 2000
s.bind((host, port))
s.listen(2) # here 2 means the maximum number of clients that can connect to the server is 2
conn,addr = s.accept()
for data in fileinput.input('some file I previously created')
    conn.send(data)
conn.close()

So, here pretty much is the client-server communication. (Only the Server part). The question is: This script can implement communication be开发者_StackOverflow中文版tween one client and one server.

How to fulfill communication between one server and multiple clients. Let's say I have 6 numbers in the file. I wish to transmit the first 3 to client-A, the 4th to client-B and the rest to client-C.

How to make this happen?

I appreciate your precious and experienced skills.


Use Twisted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜