<div dir="ltr"><div class="gmail_default" style=""><div class="gmail_default" style=""><font size="1">That's what I do.</font></div><div class="gmail_default" style=""><font size="1"><br></font></div><div class="gmail_default" style=""><font size="1">case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:</font></div><div class="gmail_default" style=""><font size="1">        {</font></div><div class="gmail_default" style=""><font size="1">            char client_name[512];</font></div><div class="gmail_default" style=""><font size="1">            char remote_client_ip[64];</font></div><div class="gmail_default" style=""><font size="1">            int fd = 0;</font></div><div class="gmail_default" style=""><font size="1">            if (wsi)</font></div><div class="gmail_default" style=""><font size="1">                fd = libwebsocket_get_socket_fd(wsi);</font></div><div class="gmail_default" style=""><font size="1"><br></font></div><div class="gmail_default" style=""><font size="1"><span class="" style="white-space:pre">                      </span>libwebsockets_get_peer_addresses(wsicont,</font></div><div class="gmail_default" style=""><font size="1">                                wsi, fd, </font></div><div class="gmail_default" style=""><font size="1">                                client_name, sizeof(client_name),</font></div><div class="gmail_default" style=""><font size="1">                                remote_client_ip, sizeof(remote_client_ip));</font></div><div class="gmail_default" style=""><font size="1"><br></font></div><div class="gmail_default" style=""><font size="1"><span class="" style="white-space:pre">                  </span>websocket->log(LOG_INFO, "websocket request from %s (%s)",</font></div><div class="gmail_default" style=""><font size="1"><span class="" style="white-space:pre">                                                             </span>client_name, remote_client_ip);</font></div><div class="gmail_default" style=""><font size="1">            break;</font></div><div class="gmail_default" style=""><font size="1">        }</font></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 2, 2015 at 5:19 AM, Roger Light <span dir="ltr"><<a href="mailto:andy.green@linaro.org" target="_blank">andy.green@linaro.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Susy,<br>
<br>
You should get the socket from lws using libwebsocket_get_socket_fd(),<br>
then use getpeername() to get information about the remote side of the<br>
connection.<br>
<br>
<a href="http://www.retran.com/beej/getpeernameman.html" rel="noreferrer" target="_blank">http://www.retran.com/beej/getpeernameman.html</a><br>
<br>
Cheers,<br>
<br>
Roger<br>
<div><div class="h5"><br>
<br>
On Thu, Oct 1, 2015 at 8:11 AM, amber susy <<a href="mailto:andy.green@linaro.org">andy.green@linaro.org</a>> wrote:<br>
> Hi all,<br>
><br>
> How can I solve, that when a client connects to the websocket server, the<br>
> server gets the information what the port number the client uses is? (port<br>
> on client side)<br>
><br>
> I would need this to differentiate clients from same LAN (connecting from<br>
> behind the same router).<br>
> For such clients, the IP -currently without port- is same, thus not enough<br>
> to differentiate them.<br>
><br>
> Thanks and Regards<br>
> Susy<br>
><br>
</div></div>> _______________________________________________<br>
> Libwebsockets mailing list<br>
> <a href="mailto:Libwebsockets@ml.libwebsockets.org">Libwebsockets@ml.libwebsockets.org</a><br>
> <a href="http://ml.libwebsockets.org/mailman/listinfo/libwebsockets" rel="noreferrer" target="_blank">http://ml.libwebsockets.org/mailman/listinfo/libwebsockets</a><br>
><br>
_______________________________________________<br>
Libwebsockets mailing list<br>
<a href="mailto:Libwebsockets@ml.libwebsockets.org">Libwebsockets@ml.libwebsockets.org</a><br>
<a href="http://ml.libwebsockets.org/mailman/listinfo/libwebsockets" rel="noreferrer" target="_blank">http://ml.libwebsockets.org/mailman/listinfo/libwebsockets</a><br>
</blockquote></div><br></div>