Dear,
I am not sure if this list is the right place to ask my question.
Actually, I am using Python to investigate my work in SDN using Ryu Controller.
Obviously, I have two python applications.
the first one sends object using socket to the second.
The object type is <class
'ryu.ofproto.ofproto_v1_3_parser.OFPPacketIn'>.
I have used pickle and json, but they could not send it.
I am trying Jsonpickle right now which send it well
def sendToC2(self, y):
data = jsonpickle.encode(y)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = socket.gethostname() # Get local machine name
port = 12345 # Reserve a port for your service.
s.connect((host, port))
s.sendall(data)
#print s.recv(1024)
s.close
But the second application cannot decode it.
s = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)
#host = socket.gethostname() # Get local machine name
port = 12345 # Reserve a port for your service.
s.bind(('', port)) # Bind to the port
s.listen(5) # Now wait for client connection.
c, addr = s.accept() # Establish connection with client.
while True:
x = c.recv(2048)
print 'Got connection from', addr
rdata =jsonpickle.decode(x)
if not rdata:
break
print 'the pakt is:', rdata
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/mininet/ryu/ryu/app/C1.py", line 197, in foo
rdata =jsonpickle.decode(x)
File "/usr/local/lib/python2.7/dist-packages/jsonpickle/__init__.py", line 155 , in decode
return unpickler.decode(string, backend=backend, keys=keys, classes=classes)
File "/usr/local/lib/python2.7/dist-packages/jsonpickle/unpickler.py", line 26 , in decode
return context.restore(backend.decode(string), reset=reset, classes=classes)
File "/usr/local/lib/python2.7/dist-packages/jsonpickle/backend.py", line 197, in decode
raise e
ValueError: Unterminated string starting at: line 1 column
2028 (char 2027)
Could you help me
Best
A.Soliman