サーバー (Python で実装) クライアント (C で実装) アプリケーションに取り組んでいます。サーバー側 (Python) で構造体モジュールを使用して、C クライアントから受信した raw バイトをアンパックしたいと考えています。
私のC構造(Cクライアントから):
typedef struct lokesh{
int command;
union
{
struct{
int data[100];
int ttl[100];
};
struct{
char config[256];
};
};
} mystructdata;
サーバー側での解凍 (Python):-
import struct
data,address=socket.recvfrom(1024)
result=struct.unpack('<i 2048s',data)
print(result[0])
しかし、私はエラーが発生しています:-
struct.error: unpack require object of size 2052
'<i 2048s'
unpack メソッドのフォーマット文字列引数に問題があると思います。
編集 :-
'<i 2048s'
今、フォーマット文字列をフォーマット文字 列に置き換えました'<i 256s'