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

ff_connect cannot connect to remote address. #534

Open
Water-Melon opened this issue Jul 27, 2020 · 1 comment
Open

ff_connect cannot connect to remote address. #534

Water-Melon opened this issue Jul 27, 2020 · 1 comment

Comments

@Water-Melon
Copy link

Water-Melon commented Jul 27, 2020

In the same server, using another NIC to ping remote IP is ok, but bound by f-stack(dpdk) can not connect on it.
code:
...
in_addr.sin_family = AF_INET;
in_addr.sin_port = htons(remote_port);
in_addr.sin_addr.s_addr = htonl(inet_addr(remote_ip));
ff_connect(connfd, (struct linux_sockaddr *)&in_addr, sizeof(in_addr));
...
if is blocking mode, it will return < 0 and error message is: Operation not permitted

@Water-Melon Water-Melon changed the title EPOLLOUT will not be triggered. EPOLLOUT will not be triggered. [BUG] Jul 27, 2020
@Water-Melon Water-Melon changed the title EPOLLOUT will not be triggered. [BUG] ff_connect cannot connect to remote address. Jul 27, 2020
@jfb8856606
Copy link
Contributor

F-Stack don't support blocking mode, you should use ff_connect like this.

    ff_init(argc, argv);

    int  clientfd = ff_socket(AF_INET, SOCK_STREAM, 0);
    printf("client:%d\n", clientfd);
    if (clientfd>0)
    {
        int on=1;
        ff_ioctl(clientfd, FIONBIO, &on);

        struct sockaddr_in server_sock;
        bzero(&server_sock,sizeof(server_sock));
        server_sock.sin_family = AF_INET;
        server_sock.sin_port = htons(80);
        inet_pton(AF_INET,"your ip",&(server_sock.sin_addr));

        int ret = ff_connect(clientfd,(struct linux_sockaddr *)&server_sock,sizeof(struct sockaddr_in));
        if (ret < 0 && errno != EINPROGRESS)
           printf("conn failed, clientfd = %d,ret=%d,%d,%s\n",clientfd,ret,errno,strerror(errno));
        else 
            printf("conn suc\n");
        printf("create_socket_cn clientfd = %d,ret=%d,%d,%s\n",clientfd,ret,errno,strerror(errno));
    }
    //EV_SET(&kevSet, clientfd, EVFILT_READ|EVFILT_WRITE, EV_ADD, 0, MAX_EVENTS, NULL);
    EV_SET(&kevSet, clientfd, EVFILT_WRITE, EV_ADD, 0, MAX_EVENTS, NULL);

    assert((kq = ff_kqueue()) > 0);

    /* Update kqueue */
    ff_kevent(kq, &kevSet, 1, NULL, 0, NULL);

    ff_run(loop, NULL);

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

2 participants