2

Is there a way to know the connected clients socket descriptor at the Server end while using on Lua enabled webservers(like Lighttpd,Apache)?

I tested for getting the clients IP address and HTTP headers and am able to receive them properly.

I could not find any function in Lua Socket(2.0.3) which would take a HTTP request and return the socket descriptor for the request.

If the available Lua enabled webserver do not give these functions, is there any way we can try this?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Sudhi
  • 21
  • 2
  • 2
    what do you mean by "return the socket descriptor for the request"? You can only get a socket by using `socket.bind` or `socket.listen` methods, but this has nothing to do with the socket used on the client side. You can get IP/port of the client by using `server:getpeername`, if that's what you need. – Paul Kulchenko Aug 28 '12 at 18:41
  • The return value of the server:accept( ) is a client object which represents the client connected. If I can get the connected client object of HTTP client request then I can do send and recv operations on that object. I am experimenting to implement reverseHttp on lua enabled webservers. – Sudhi Aug 29 '12 at 05:43
  • 1
    I'm still a bit confused. You are asking for "a way to know the connected clients socket descriptor" and yet saying "server:accept( ) is a client object which represents the client connected". Do you mean that when you do `http.request(...)` you can't get the socket that is hidden inside http.lua implementation? If that's the case, then you may need to implement the interaction yourself. Although you may want to check "create" parameter in http.request() to see if you can get to socket that way ([http](http://w3.impa.br/~diego/software/luasocket/http.html)). – Paul Kulchenko Aug 29 '12 at 22:36

0 Answers0