python socket之进程间通信
2009-10-20 18:45
169 查看
最近用到python的socket实现进程间通信,发现网上的资料很零散,例子极少。写了一个example:
Server:
Client:
Server:
if __name__ == '__main__': import socket sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) import os if os.path.exists('/tmp/UNIX.d'): os.unlink('/tmp/UNIX.d') sock.bind('/tmp/UNIX.d') sock.listen(5) while True: connection,address = sock.accept() print "Data : %s"%connection.recv(1024); connection.send("hello") connection.close()
Client:
if __name__ == '__main__': import socket sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect("/tmp/UNIX.d") import time time.sleep(2) sock.send('hello') print sock.recv(1024) sock.close()
相关文章推荐
- Python socket 进程间通信
- Python socket 进程间通信
- python多进程笔记2 - 进程间通信:队列,管道,文件,共享内存,信号量,事件,互斥锁,socket
- Python使用Socket 进行进程间通信
- Python socket 实现进程间通信
- SocketTornad.IO 0.1.3 : Python Package Index
- python socket编程
- Python socket.error: [Errno 98] Address already in use的原因和解决方法
- Python天天美味(27) - 网络编程起步(Socket发送消息)
- UNIX_SOCKET 进程间通信
- python socket向百度发送http长连接请求 并做搜索
- Python socket编程
- Python Socket编程详解
- python学习之 socket
- Python Twisted框架中socket通讯
- Python Socket套接字
- Python socket C/S结构的聊天室应用实现
- Python中的TCP socket写法示例
- python socket编程详细介绍
- Python Socket编程简介