6

I have a C socket server who receive XDR data. I have wrote a C and a Java client. I am trying to write a Python client using xdrlib.

import xdrlib

p = xdrlib.Packer()
p.pack_int(5) 
p.pack_int(4)
p.pack_int(3)
data = p.get_buffer()

When i decode this via the server data are different. This is because data are encoded as to be read via a xdrmem decoder. (they do not have start and end of record).

Does anyone know if there is a library for python who support the creation of xdr records? In c this is done via xdrrec_create and in Java this is called XdrTcpEncodingStream.

Stefano
  • 3,981
  • 8
  • 36
  • 66
  • Minimum packet length, packet block size. Need create packet pattern for global use. Every packet contained a block definition. Don't communicate without header definition. – dsgdfg Apr 07 '16 at 13:46
  • sorry... can you rephrase your comment? i did not get what you explained... – Stefano Apr 07 '16 at 14:15

1 Answers1

-2

I mostly see xdrlib is the package mostly used. When you have processes that can be done in C or Java, You can just run them in c/java and use it in python by using and interface created by Swig. Let me know if my understanding doesn't suit the scenario.

Venkata Vamsy
  • 92
  • 1
  • 6
  • well... i used Swig in the past but if I use the C library xdrrec_create uses different callbacks for retriving the data. I am afraid that this will not be so easy to map in python. I did not try to wrap around the Java version. If I can find a Python module that suit my needs I prefer otherwise I think I will simply stick to java to write my client (or wrap the Java library in swig for python) – Stefano Apr 07 '16 at 07:23
  • he is searching for a python module. Swig is always a solution but not what he is asking for – Cristas Apr 07 '16 at 07:25