Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with continue communicating #1

Open
hellofinch opened this issue Mar 27, 2023 · 0 comments
Open

Trouble with continue communicating #1

hellofinch opened this issue Mar 27, 2023 · 0 comments

Comments

@hellofinch
Copy link

I run your code, and it works fine.

I modify your code and want the client to send something to the server. But I failed.
The code in client:

#include "rdma_socket.hpp"
#include <unistd.h>

int main(int argc, char* argv[]) {
    rdma_socket client(RDMA_PS_TCP);

    client.resolve("12.7.14.35", 8000);
    client.create_qp();
    
    char* mem = new char[4096];
    client.post_recv(mem, 4096);

    client.connect();
 
    struct ibv_wc wc = client.recv_comp();
    printf("%s\n", reinterpret_cast<char*>(wc.wr_id));
    
    char* data = new char[4096];
    std::memcpy(data, "Hello serve!", 13);
    client.post_send(data, 4096);
    printf("ttt\n");
    sleep(1);
    printf("rrr\n");
    wc = client.send_comp();
    printf("xxx\n");
    return 0;
}

The server code:

#include "rdma_socket.hpp"
#include <unistd.h>

int main(int argc, char* argv[]) {
    rdma_socket server(RDMA_PS_TCP);

    server.bind("12.7.14.35", 8000);
    server.listen();
    rdma_socket rclient = server.accept();

    char* data = new char[4096];
    char* datax = new char[4096];
    std::memcpy(data, "Hello World!", 13); 
    // std::memcpy(datax, "Hello World!", 13); 

    rclient.post_send(data, 4096);
    
    rclient.post_recv(datax, 4096);
    std::cout << "yyy" << std::endl;
    
    struct ibv_wc wc = rclient.send_comp();
    printf("zzz\n");
    wc = rclient.recv_comp();
    printf("%s\n", reinterpret_cast<char*>(wc.wr_id));
    
    return 0;
}

When I run the code, both sides are stuck. The zzz didn't show up on the server's side. And on the client's side, the xxx didn't show up.

How can I make the code work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant