Convert C++ code to python
-
Hi
Can any one help me convert the C++ code to python
char buf[1024];
int nBufLen1;CString sendBuffer("$Magic $Command AudienceCount 0 10000"); //int nBufLen1 = sendBuffer.GetLength(); buf\[0\] = 0; buf\[1\] = 0; WORD len = sendBuffer.GetLength() \* 2; nBufLen1 = len + 5; // length of message buf\[2\] = (BYTE)len; char \*pStr = T2A(sendBuffer); strncpy(&buf\[3\],pStr,len); // actual string to send buf\[len + 3\] = 0; buf\[len + 4\] = 0; if(sock.Send (&buf,nBufLen1) != nBufLen1) { OutputDebugString(L"Socket Send Failed"); return FALSE; }
I have a MFC C++ server(with CArchive) (serialization used) to which I need to send the data over socket.
The above code works in C++ client, need to replicate same in python so that it might work.What I have tried:
I have been trying to use seasnake, but unable to install using pip.
A few online converter are also there, but many are not working. -
Hi
Can any one help me convert the C++ code to python
char buf[1024];
int nBufLen1;CString sendBuffer("$Magic $Command AudienceCount 0 10000"); //int nBufLen1 = sendBuffer.GetLength(); buf\[0\] = 0; buf\[1\] = 0; WORD len = sendBuffer.GetLength() \* 2; nBufLen1 = len + 5; // length of message buf\[2\] = (BYTE)len; char \*pStr = T2A(sendBuffer); strncpy(&buf\[3\],pStr,len); // actual string to send buf\[len + 3\] = 0; buf\[len + 4\] = 0; if(sock.Send (&buf,nBufLen1) != nBufLen1) { OutputDebugString(L"Socket Send Failed"); return FALSE; }
I have a MFC C++ server(with CArchive) (serialization used) to which I need to send the data over socket.
The above code works in C++ client, need to replicate same in python so that it might work.What I have tried:
I have been trying to use seasnake, but unable to install using pip.
A few online converter are also there, but many are not working.