Interprocess Communication between Python and D
Utk
bhiogade20 at gmail.com
Thu Jun 24 04:28:45 UTC 2021
I'm trying to send data from python script to D using tcp
sockets. As I'm new to D I referred to
https://forum.dlang.org/post/lqahvaeqddaddnkhpfyf@forum.dlang.org
for client and server code. When I'm sending packed data from
python it is of the form
```d
u'\x0f\x10\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\xbaH\x0c\x00'
```
basically a string! This data is successfully received on the
client side in D but when the data is changing to
```d
u'\x0f\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00'
```
I'm receiving nothing on the client-side in D.
Client code:
```d
void main() {
import std.socket, std.stdio;
auto socket = new Socket(AddressFamily.INET,
SocketType.STREAM);
char[1024] buffer;
socket.connect(new InternetAddress("127.0.0.1", 10000));
auto received = socket.receive(buffer); // wait for the
server to say hello
writeln("Server said: ", buffer[0 .. received]);
}
```
(same code as mentioned in the above link)
**Can someone please help me with this?**
Also when I'm sending the data in the 1st format, I'm receiving
```�H``` as an output on the client, what changes in code should
I make so that I receive the data in the same format as sent from
Python?
More information about the Digitalmars-d
mailing list