Sign in to follow this  
Followers 0
lawpapa

checking ports for IP-s

7 posts in this topic

Hey guys Have u got any idea how could i check the ip adress on a certain port?

is there any function for it? If no how could i write mine?

Sure i would like to do it as an auto script..

The function should decide weather the ip adress is correct or not.

It should bring 2 results yes or no.

Thanks in advance

law

Share this post


Link to post
Share on other sites



Hey guys Have u got any idea how could i check the ip adress on a certain port?

is there any function for it? If no how could i write mine?

Sure i would like to do it as an auto script..

The function should decide weather the ip adress is correct or not.

It should bring 2 results yes or no.

Thanks in advance

law

In NT, 2000 and XP you can use the DOS command "ipconfig /all" to obtain all ip address's.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@IPAddress1

IP address of first network adapter. Tends to return 127.0.0.1 on some computers.

@IPAddress2

IP address of second network adapter. Returns 0.0.0.0 if not applicable.

@IPAddress3 IP address of third network adapter. Returns 0.0.0.0 if not applicable.

@IPAddress4 IP address of fourth network adapter. Returns 0.0.0.0 if not applicable.

Edited by ChrisL

Share this post


Link to post
Share on other sites

Hmm ty for the fast replies.. but i think this is not exactly wot i need

lemme explain the problem once again.

I dont want to know my own ip adresses. B)

after typing netstat in the command line i will get the folowing results:

protokoll: tcp local adress:omnibook:1617 foreign adress: host-219.someting.com:4000

219 is the last byte of the foreign ip adress.. and its variable, will be renewed in case of reconnection

The task of my auto script is to

connect my client to the host <--- this step is done

check its ip adress <--- this is the step in what i need help

if its correct stay <--- this step wont be problem

else disconnect <--- this step wont be a problem

and connect again. <--- sure this wont mean a problem again

Can u please tell me something about this ?:o

Share this post


Link to post
Share on other sites

if your connecting to the host via tcpconnect ... then this should be your solution:

$ip = SOCKET2IP($ConnectedSocket)

Func SOCKET2IP($SHOCKET)
   $sockaddr = DLLStructCreate("short;ushort;uint;char[8]")

   $a = DLLCall("Ws2_32.dll","int","getpeername","int",$SHOCKET,"ptr",DLLStructGetPtr($sockaddr), _
                                            "int_ptr",DLLStructGetSize($sockaddr))
   If Not @error And $a[0] = 0 Then
      $a = DLLCall("Ws2_32.dll","str","inet_ntoa","int",DLLStructGetData($sockaddr,3))
      If Not @error Then $a = $a[0]
   Else
      $a = 0
   EndIf

   DLLStructDelete($sockaddr)

   Return $a
EndFunc

this should do the job (from help-file)

Share this post


Link to post
Share on other sites

ahh ty.. this is more closer. i immediatly try to do something with this function. maybe it ends my suffering B)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0