Page 1 of 2

Remote IP

Posted: Tue Feb 05, 2008 11:21 am
by SylRob
Good Morning Everyone,

IT's been a long time, isn't ! :)

Ok here is a my question, is it possible to know the Remote client IP adress when the connection goes through a ROUTER. I know that the complete ROUTE is in the TCP/IP packet. Can someone point me to the right direction,

Thank you,

Best Regards,

Posted: Tue Feb 05, 2008 4:27 pm
by SylRob
If it can help someone !

I found how to do it with Teredo ! and will explore the possibility with SNMP protocol !

Ty,

Re: Remote IP

Posted: Tue Feb 05, 2008 6:37 pm
by Enrico Maria Giordano
Hi, Sylvain! Glad to see you here again! :-)

Unfortunately I can't help you with your problem. :-(

EMG

Re: Remote IP

Posted: Tue Feb 05, 2008 6:55 pm
by SylRob
Hi Enrico,


Nice to read you my friend ! :)

I already found a solution with IPV6 and Teredo protocol, I'll give a try to the SNMP protocol, it will be mor generic !

HTH,

Sylvain

Posted: Tue Feb 05, 2008 7:27 pm
by Kleyber
Hi Sylvain,

Glad to see you here again after a long time. You're always welcome!!

Best Regards,

Posted: Tue Feb 05, 2008 7:31 pm
by SylRob
Kleyber,

Same pleasure for me kleyber ! :)

Hope things are going well for you !.

Best Regards,

Sylvain

Remote IP

Posted: Wed Feb 06, 2008 4:06 am
by AlexSchaft
Hi Sylvain,

Are you looking for the ip address of the client connecting to a server socket?

If so, you need oSocket:ClientIP()

Code: Select all

  nEchoPort                  := ::nPortNo+::nPortNo / 100

  Do While .t.
    ::oEchoSocket            := tsocket():New(nEchoPort)

    If ::oEchoSocket:lStartOK
      Exit
    Else
      nEchoPort++
    Endif
  Enddo

  ::oEchoSocket:bAccept      := {| oSocket | ::EchoAccept(oSocket:nSocket)}

  If !::oEchoSocket:Listen()
    ::Error("Monitor Listening socket error " + NTRIM(wsagetlasterror()))
  Endif

return nil

METHOD Echoaccept(pnSocket) CLASS qReceive

  Local oSocket              := nil

  oSocket                    := tsocket():Accept(pnSocket)

  oSocket:bRead              := {| poSocket |::EchoRead(poSocket)}
  oSocket:bWrite             := {| poSocket |::EchoWrite(poSocket)}
  oSocket:bClose             := {| poSocket |::EchoClose(poSocket)}

  ::Error("Listener joined from "+oSocket:Clientip(), False)

  aadd(::aaEchoSocket, {oSocket, 0, ,""})   // For flags and data

  oSocket:SendData("Welcome listener from "+oSocket:Clientip()+CRLF)
Return nil

Posted: Wed Feb 06, 2008 8:58 am
by Silvio
Alex,
Can I create on a fwh program a listbox where i can insert all Pc link to my server ?
I explain you
i have on a classroom a pc and another 24 pc link to this pc

I want see how many pc is open or not

In Vb this is possibile .. but in fwh I not Know How make it

thanks

Connecting

Posted: Wed Feb 06, 2008 10:29 am
by AlexSchaft
Yes,

The main pc runs the listen socket, and all the others connect to it on startup.

Increment a counter when they connect, and decrement when they disconnect

Posted: Wed Feb 06, 2008 10:52 am
by SylRob
Alex,

I'm really familiar with the socket function ! :). This won't work if the client connection come from the internet over a Router you'll obtain the ROUTER IP !

Best Regards,

Sylvain

Posted: Wed Feb 06, 2008 2:47 pm
by Antonio Linares
Sylvain,

Glad to see you again :-)

Posted: Wed Feb 06, 2008 3:00 pm
by SylRob
Hey Antonio,

Thank's for the kind words, it was nice to read you again Antonio !

Best Regards,

Sylvain

Re: Remote IP

Posted: Wed Feb 06, 2008 3:39 pm
by Patrick Mast
SylRob wrote:Good Morning Everyone,

IT's been a long time, isn't ! :)

Ok here is a my question, is it possible to know the Remote client IP adress when the connection goes through a ROUTER. I know that the complete ROUTE is in the TCP/IP packet. Can someone point me to the right direction,

Thank you,

Best Regards,
Hey Mate! ;-)
Glad to see you here!

I use my Bekz.net server to receive the user's IP address. I have a small web site that just printts the user's IP address. Works all the time :)

Patrick

Re: Remote IP

Posted: Wed Feb 06, 2008 3:41 pm
by Patrick Mast
Patrick Mast wrote:
SylRob wrote:Good Morning Everyone,

IT's been a long time, isn't ! :)

Ok here is a my question, is it possible to know the Remote client IP adress when the connection goes through a ROUTER. I know that the complete ROUTE is in the TCP/IP packet. Can someone point me to the right direction,

Thank you,

Best Regards,
Hey Mate! ;-)
Glad to see you here!

I use my Bekz.net server to receive the user's IP address. I have a small web site that just printts the user's IP address. Works all the time :)

Patrick
You can also use http://whatismyipaddress.com/ or similar.
Just read the HTML in a variable en take out the IP address.

Patrick

Posted: Wed Feb 06, 2008 4:02 pm
by SylRob
Hello Patrick,

This won't work either, I'm not using HTTP protocol so I can't read session variable and second it's not my ROUTER IP that I need and I can't run code on the client side because any other software can connect to my TCP server (with the right protocol)

I wrote a TCP server that receive a client connection from Internet and the connection go through the ROUTER to reach my TCP server, so that's why I received the ROUTER IP in ALL languages that I tested ! :)

The only way to get the REAL client IP address is to use IPv6 TEREDO protocol or implement the STUN protocol (server outside the ROUTER who relay the connection to the REAL server), other thing I'll expirement at the moment I have time is to get the ROUTER table with SMNP and write a trace route routine to the final HOP to get the real IP address even if the client his behind a router at the other side !

Best Regards,

It was a real pleasure tu read you Patrick !

Sylvain