[Libwebsockets] how to set client socket local port

Andy Green andy at warmcat.com
Wed Jan 12 16:38:56 CET 2022

On 1/12/22 15:28, Sylvain Saunier wrote:
> Hi Andy,
> first, i wish you an happy new year
> second, sorry for my english in advance...
> so, i would like to set the binding "local port" for a client connection 
> when i use lws_client_connect_via_info().
> i know i have possibility to set the local IP with iface (in 
> lws_client_connect_info)
> there is also information port but it is for the "remote port"
> should be possible to add a new info to set the "local port" instead 
> default 0  set in function
> lws_client_connect_3_connect when calling lws_socket_bind. ?

Yes I think you'd have to add a uint16_t member for it in the client 
connection info struct... zero would mean pick an ephemeral port as now. 
  You'd have to add stuff as you say in client_connect_3 to make that 

Patch is welcome...


More information about the Libwebsockets mailing list