iOS 클라이언트가있는 Python tcp 서버가 있습니다. 그것은 데이터를 보내고 받아 들일 수 있습니다. 유일한 문제는 인코딩과 관련이 있습니다. 파이썬 서버에 JPEG를 보내고 서버의 JPEG에 데이터를 쓰려고합니다. jpeg가 계속 손상됩니다.TCP를 통해 Python 서버에 JPEG NSData 보내기
클라이언트의 Obj-C 코드 :
from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
class IphoneChat(Protocol):
def connectionMade(self):
self.factory.clients.append(self)
print "clients are ", self.factory.clients
def connectionLost(self, reason):
self.factory.clients.remove(self)
def dataReceived(self, data):
file = open('test.jpeg','w')
file.write(data)
file.close()
factory = Factory()
factory.clients=[]
factory.protocol = IphoneChat
reactor.listenTCP(2000, factory)
print "Iphone Chat server started"
reactor.run()