Closed Akki-401 closed 1 year ago
Hello,
Unfortunately, the variable client_address
in the struct _u_request
isn't meant to specify the client IP address during a ulfius_send_http_request
call. This variable is used to get the client IP address in a webservice callback.
It is not possible to specify the interface to use in your case.
Hi @babelouest,
Thanks for your quick response.
I'm using ulfius here as a standalone client. It doesn't have any callback registered. So I want REST request should being sent from specific IP address (my machine is having multiple interface (IP address)). Is there any way to achieve this scenario?
Hello @Akki-401 ,
Unfortunately, as I said below, ulfius doesn't allow to specify a network interface for the outgoing HTTP requests, sorry. You may try with libcurl which seems to have such ways: https://curl.se/libcurl/c/CURLOPT_INTERFACE.html
Hi @babelouest
Thanks for your suggestion. Will try with libcurl.
Also thanks a lot for your prompt response.
I'm filling the client_address of _u_request with IP add to bind REST client with specific interface. But REST Request is being sent from other interface in my case. Please find below code snippet:
struct _u_request req_list; struct sockaddr_in p = (struct sockaddr_in )calloc(1,sizeof(sockaddr_in)); p->sin_family = AF_INET; p->sin_addr.s_addr = inet_addr("10.211.10.169"); p->sin_port = htons(40000); req_list.client_address = (struct sockaddr*)&p;
Please let me know If i'm doing it correctly?