pythonでXMLSocket
0x00で区切られて,どんどん送られていくる.のでそれを拾うだけ.
class XMLSocket : def __init__(self, host=None, port=None) : self.host = host self.port = port self.sock = None self.buf = "" def connect(self) : self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) def send(self, string) : self.sock.sendall(string+chr(0)) def recv(self) : while self.buf.find(chr(0)) == -1 : self.buf += self.sock.recv(1024) string = self.buf[:self.buf.find(chr(0))] self.buf = self.buf[self.buf.find(chr(0))+1:] return string
使用例
xmlsocket = XMLSocket(ホスト, ポート) xmlsocket.connect() xmlsocket.send(送りたいデータ) print xmlsocket.recv() # 受信データを表示