Hello!
I'm trying to establish a connection between a python server and a d client. The data is been transferred properly only once and then the d client doesn't wait for any further data and returns an error ```Socket.ERROR``` and exists and doesn't wait for further incoming data from the Python server. From Python, the data is been sent whenever the user sends a request but instead of waiting for incoming requests the D client just accepts the data 1st time and then throws an error and exits.
The code snippet is as below:
```
bool get_req_from_socket(Socket socket) {

    ubyte[] rawTrHeader;
    ubyte[] buffer;

    writeln("Waiting for data from socket");
    while (rawTrHeader.length < 16) {
      import std.string: format;

      buffer.length = 16 - rawTrHeader.length;
      auto ret = socket.receive(buffer);
uvm_info("SOCKET", format("Received %d bytes from socket", ret),
               UVM_DEBUG);
      if (ret == Socket.ERROR)
        uvm_fatal("SOCKET", "Error receiving data from socket");
      if (ret == 0)
        uvm_fatal("SOCKET", "Got insufficient bytes for TrHeader");
      // now slice the buffer to get the part...
      rawTrHeader ~= buffer[0 .. ret];
    }
    ...
    ...
  }

```
This is the function (infinitely called while it returns ```true```) that accepts the data and returns ```true``` or ```false``` depending on if data is received or not respectively.
The error I'm receiving is:
```
Waiting for data from socket
UVM_INFO ../testbench/apb.d(375) @ 130000: reporter@@apb_seq [SOCKET] Received -1 bytes from socket UVM_FATAL ../testbench/apb.d(378) @ 130000: reporter@@apb_seq [SOCKET] Error receiving data from socket
```
Please help me to resolve this issue.


Reply via email to