Jump to content
Sign in to follow this  
Ascend4nt

Network Interface Info, Statistics, and Traffic

Recommended Posts

Works on 7 x64. Thanks for sharing.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

Thanks for the tests.  Btw, my 'splash window' height calculations aren't very scientific as you've seen from my other thread. :unsure:


Share this post


Link to post
Share on other sites

Ok, fine.  I'm never happy leaving things looking halfway done.  Now I've added IP and ICMP statistics.  See 1st post. Oh, and ICMP doesn't change that often - to force an increase, do a 'ping' from the command prompt.


Share this post


Link to post
Share on other sites

The splash screen is OK this time. I tested the new version and pinged a machine, it registered the packet being sent with your UDF.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

I've update this UDF with a bunch of more information.  Network adapters and interfaces are now queryable. Arrays of information about each network interface are now returned from certain functions.  Inside the arrays are indexes which can be used to query network statistics for each network interface.

This is a pretty big change from my first version of Network Statistics (I call it version 2!), so if anyone inquires about it, I could upload the old version again.  However, I plan to split the main UDF from the example in the future.

Updates:

2013-07-02:

 Fixed: indexing, updated and enhanced output

 Changed: Various functions return arrays even if failure - this is to make XP pre-SP1 and also collection of IPv6 less troublesome. @error should still be checked on return though!

 Added: Adapter and Interface information and statistics collection

See the first post


Share this post


Link to post
Share on other sites

I'm getting an error:

C:\_Downloads\NetworkStatistics.au3 (1267) : ==> Subscript used with non-Array variable.:
ConsoleWrite("Interface #"&$i+1&" Entry Info: [0] Interface Index = " & $aNIEntryInfo[0] & ", [1] Interface Type = " & $aNIEntryInfo[1] & ", ...
ConsoleWrite("Interface #"&$i+1&" Entry Info: [0] Interface Index = " & $aNIEntryInfo^ ERROR

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

UEZ, thanks.. can you insert this line after the call to _Network_InterfaceInfo() and tell me what it reports?:

ConsoleWrite("_Network_InterfaceEntryInfo return, @error = " & @error & ", @extended = " & @extended & @CRLF)

Also, is there information reported to the console from the call to _Network_IPAllAddressTable() on?  I've tested this so far in 3 different VM environments, so I was hopeful.. <_<


Share this post


Link to post
Share on other sites

That is really really peculiar.  There's nothing in the documentation for GetIfEntry that mentions ERROR_FILE_NOT_FOUND (2), and in light of what the function does it really makes no sense to give that specific error.

I also asked if you had any console output from the call to _Network_IPAllAddressTable() onwards.  It seems it must return an array if it doesn't crash until _Network_InterfaceInfo()..  does the data look valid? Perhaps adding that ConsoleWrite() debug message after a call to that function could help as well.

The only thing I can guess right now is that there's an index # that isn't matching up somewhere..

thanks again for your help


Share this post


Link to post
Share on other sites

This is the complete output:

IP [IPv4] Stats: [0]  = IP Forwarding Status: [1 = Enabled, 2 = Disabled] : 2, [1]  = Default initial time-to-live (TTL) for datagrams : 64
, [2]  = # Received Datagrams : 97579, [3]  = # Received Datagrams w/Header errors : 0, [4]  = # Received Datagrams w/Address errors : 14
, [5]  = # Forwarded Datagrams : 0, [6]  = # Received Datagrams w/Unknown Protocol : 0, [7]  = # Received Datagrams Discarded : 366
, [8]  = # Received Datagrams Delivered : 99864, [9]  = # Requested Outgoing Datagrams : 79017, [10] = # Outgoing Datagrams Discarded : 0
, [11] = # Transmitted Datagrams Discarded : 0, [12] = # Datagrams w/o Routes that were Discarded : 0, [13] = TimeOut for Reassembling Incoming Fragmented Datagrams : 60
, [14] = # Datagrams Requiring Reassembly : 0, [15] = # Datagrams Successfully Reassembled : 0, [16] = # Datagrams that Failed to be Reassembled : 0
, [17] = # Datagrams that were Fragmented Successfully : 0, [18] = # Datagrams not Fragmented, and Discarded : 0, [19] = # Fragments created (for Datagrams) : 0
, [20] = # of Interfaces : 6, [21] = # of IP addresses associated with PC : 43, [22] = # of Routes in the Routing table : 14
-----------------------------------------
IP [IPv6] Stats: [0]  = IP Forwarding Status: [1 = Enabled, 2 = Disabled] : 2, [1]  = Default initial time-to-live (TTL) for datagrams : 128
, [2]  = # Received Datagrams : 0, [3]  = # Received Datagrams w/Header errors : 0, [4]  = # Received Datagrams w/Address errors : 0
, [5]  = # Forwarded Datagrams : 0, [6]  = # Received Datagrams w/Unknown Protocol : 0, [7]  = # Received Datagrams Discarded : 111
, [8]  = # Received Datagrams Delivered : 0, [9]  = # Requested Outgoing Datagrams : 800, [10] = # Outgoing Datagrams Discarded : 0
, [11] = # Transmitted Datagrams Discarded : 0, [12] = # Datagrams w/o Routes that were Discarded : 8, [13] = TimeOut for Reassembling Incoming Fragmented Datagrams : 60
, [14] = # Datagrams Requiring Reassembly : 0, [15] = # Datagrams Successfully Reassembled : 0, [16] = # Datagrams that Failed to be Reassembled : 0
, [17] = # Datagrams that were Fragmented Successfully : 0, [18] = # Datagrams not Fragmented, and Discarded : 0, [19] = # Fragments created (for Datagrams) : 0
, [20] = # of Interfaces : 10, [21] = # of IP addresses associated with PC : 30, [22] = # of Routes in the Routing table : 13
-----------------------------------------
TCP [IPv4] Stats:[0] Rto Algorithm = 3,[1] Rto Min = 10,[2] Rto Max = 4294967295,[3] #Max Connections = 4294967295,[4] #Active Opens = 1656,[5] #Passive Opens = 17
 [6] #Failed Connection Attempts = 1508,[7] #Established Connections that were Reset = 359,[8] #Established Connections [current] = 26
 [9] #Recvd Segments = 95689,[10] #Sent Segments = 73938,[11] #Retransmitted Segments = 3735
 [12] #Receive Errors = 0,[13] #Sent Segments with Reset Flag = 2058,[14] #Connections = 87
-----------------------------------------
TCP [IPv6] Stats:[0] Rto Algorithm = 3,[1] Rto Min = 10,[2] Rto Max = 4294967295,[3] #Max Connections = 4294967295,[4] #Active Opens = 0,[5] #Passive Opens = 0
 [6] #Failed Connection Attempts = 0,[7] #Established Connections that were Reset = 0,[8] #Established Connections [current] = 0
 [9] #Recvd Segments = 0,[10] #Sent Segments = 0,[11] #Retransmitted Segments = 0
 [12] #Receive Errors = 0,[13] #Sent Segments with Reset Flag = 0,[14] #Connections = 59
-----------------------------------------
UDP [IPv4] Stats: [0] #Recvd Datagrams = 9163,[1] #Discarded Datagrams [invalid port] = 359,[2] #Erroneous Datagrams = 7
 [3] #Sent Datagrams = 4827,[4] #UDP Listener Entries = 27
-----------------------------------------
UDP [IPv6] Stats: [0] #Recvd Datagrams = 0,[1] #Discarded Datagrams [invalid port] = 111,[2] #Erroneous Datagrams = 0
 [3] #Sent Datagrams = 657,[4] #UDP Listener Entries = 7
-----------------------------------------
ICMP [IPv4] Stats: [0] = # Incoming ICMP Messages : 10, [1] = # Incoming ICMP Errors : 0, [2] = # Outgoing ICMP Messages : 13, [3] = # Outgoing ICMP Errors : 0
-----------------------------------------
ICMP [IPv6] Stats: [0] = # Incoming ICMP Messages : 0, [1] = # Incoming ICMP Errors : 0, [2] = # Outgoing ICMP Messages : 35, [3] = # Outgoing ICMP Errors : 0
-----------------------------------------
# of adapters: 5
Adapter Index #13, Name = \DEVICE\TCPIP_{F5C17D50-4BE2-4008-BA0A-76067ABE7DE2}
Adapter Index #849, Name = \DEVICE\TCPIP_{4CD51587-472C-41E3-B0FD-C92CDA50FB20}
Adapter Index #786, Name = \DEVICE\TCPIP_{B73941B0-2376-4882-B70B-76B0F0ED8209}
Adapter Index #787, Name = \DEVICE\TCPIP_{B08246C5-DAC4-4823-A0A2-BD3F077BF4CC}
Adapter Index #15, Name = \DEVICE\TCPIP_{D2D5B3E5-1958-4C19-A719-BC16A5ABB6C5}
-----------------------------------------
+ Added Interface (index #0), Intel(R) 82577LM Gigabit Network Connection
+ Added Interface (index #786), VMware Virtual Ethernet Adapter for VMnet1
+ Added Interface (index #787), VMware Virtual Ethernet Adapter for VMnet8
+ Added Interface (index #849), VirtualBox Host-Only Ethernet Adapter
+ Added Interface (index #862), Microsoft 6to4 Adapter
Interface #1: [0] Index #0, [1] Type = 6, [2] Operational Status = 1, [3] Flags = 0x000000C5, [4] Physical [MAC] Address: 88-AE-1D-B1-08-30, [5] MTU =  1500
, [6] Description: Intel(R) 82577LM Gigabit Network Connection, [7] Friendly Name: Local Area Connection, [8] Adapter/Service Name [GUID] = {F5C17D50-4BE2-4008-BA0A-76067ABE7DE2}
, [9] Max Receive Speed [Vista+] = 100000000, [10] Max Transmit Speed [Vista+] = 100000000
, [11] IPv4 Address(es): 168.185.212.21, [12] IPv6 Address(es): 
, [13] Connection Type [Vista+] = 1, [14] Tunnel Type [Vista+] = 0
_Network_InterfaceEntryInfo return, @error = 3, @extended = 2
C:\_Downloads\NetworkStatistics.au3 (1268) : ==> Subscript used with non-Array variable.:
ConsoleWrite("Interface #"&$i+1&" Entry Info: [0] Interface Index = " & $aNIEntryInfo[0] & ", [1] Interface Type = " & $aNIEntryInfo[1] & ", [2] Operational Status = " & $aNIEntryInfo[2] & ", [3] Admin Status = " & $aNIEntryInfo[3] & ", [4] Physical Address = " & $aNIEntryInfo[4] & ", [5] MTU [Max Trans. Unit] in bytes = " & $aNIEntryInfo[5] & @CRLF & ", [6] Description = " & $aNIEntryInfo[6] & ", [7] Interface Name = " & $aNIEntryInfo[7] & @CRLF & ", [8] Last change [1/100th second] = " & $aNIEntryInfo[8] & ", [9] Interface Speed [bps] = " & $aNIEntryInfo[9] & @CRLF & ", [10] # Recvd Data [in Octets] = " & $aNIEntryInfo[10] & ", [11] # Recvd Unicast Packets = " & $aNIEntryInfo[11] & ", [12] # Recvd Non-Unicast Packets = " & $aNIEntryInfo[12] & ", [13] # Recvd Packets Discarded [no error] = " & $aNIEntryInfo[13] & ", [14] # Recvd Packets Discarded [error] = " & $aNIEntryInfo[14] & ", [15] # Recvd Packets Discarded [unk. protocol] = " & $aNIEntryInfo[15] & @CRLF & ", [16] # Sent Data [in Octets] = " & $aNIEntryInfo[16] & ", [17] # Sent Unicast Packets = " & $aNIEntryInfo[17] & ", [18] # Sent Non-Unicast Packets = " & $aNIEntryInfo[18] & ", [19] # Sent Packets Discarded [no error] = " & $aNIEntryInfo[19] & ", [20] # Sent Packets Discarded [error] = " & $aNIEntryInfo[20] & @CRLF & ", [21] Transmit Queue Length [n/a] = " & $aNIEntryInfo[21] & @CRLF)
ConsoleWrite("Interface #"&$i+1&" Entry Info: [0] Interface Index = " & $aNIEntryInfo^ ERROR
->11:51:04 AutoIt3.exe ended.rc:1

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks, I'm gonna review it and see if there's something askew.  I haven't seen an index # 0 yet, so that's curious..


Share this post


Link to post
Share on other sites

Okay, apparently that 0 index is wrong and should be 13.  I *believe* this is due to my checks against IPv6Index.  Could you possibly locate the line

               " If $nIPAAStSize > 108 Then    ; XP SP1+ O/S Structure?"

and change that and the whole IF-Endif to read this:

                If $nIPAAStSize > 108 Then    ; XP SP1+ O/S Structure?
                    ; If IPv6 index is different than IPv4 Index, AND non-zero, use the latter
                    $nTemp = DllStructGetData($stIP_ADAPTER_ADDRESSES, "Ipv6IfIndex")
                    If $nTemp And $nTemp <> $aIPAddrTableEntries[$nNumEntries][0] Then
                        $aIPAddrTableEntries[$nNumEntries][0] = $nTemp
                    EndIf
                EndIf

Hopefully that would fix the problem.  I'm still not even sure if its worth checking Ipv6IfIndex yet, so I may modify that in the future.  However, the above code at least tests for a 0 condition, and won't change an index if Ipv6IfIndex is 0.

Thanks!


Share this post


Link to post
Share on other sites

nice!  New version uploaded!  Thx for the help spotting the error

Edited by Ascend4nt

Share this post


Link to post
Share on other sites

I Got Eror..

When I'm Disconnect Modem..

LINE 1340

$sSplashText &=StringFormat("%45,56s", $aNIEntryInfo[6] & @CRLF
$sSplashText &=StringFormat("%45,56s", $aNIEntryInfo^ ERROR
     
Error: Subscript used with non-Array variable

Edited by setengahgila

Share this post


Link to post
Share on other sites

I Got Eror..

When I'm Disconnect Modem..

....

 

A modem?! Really? :o   I thought those were all gone by now haha..

But anyway.. to the problem.  If you disconnect or disable a network interface, the index # assigned to it will fail to work, or possibly be reassigned when the device is reenabled.  But, just to be thorough here.. could you please insert this code and let me know what it reports when you disconnect the modem:

        $aNIEntryInfo = _Network_InterfaceEntryInfo($aIPAllAddrTable[$i][0])
        If @error Then
            ConsoleWrite("_Network_InterfaceEntryInfo return, @error = " & @error & ", @extended = " & @extended & @CRLF)
            ExitLoop
        EndIf

That goes in the For $i = 0 To $nIPs - 1 loop, line 1334.  It *should* return error code ERROR_NOT_FOUND (1168), if I understand it correctly.

The only way to get around the problem of disconnected devices is to rescan for devices using _Network_IPAllAddressTable().  But before we go there, it'd be good to see what kind of error code is returned.

Thanks for your help


Share this post


Link to post
Share on other sites

Updated today - version 3 (by my reckoning)!  This is now a full fledged Network Interface Information and Statistics UDF module.

2013-07-06:

 Added: Much more Adapter Information

 Changed: Example is now separate from the UDF

 Fixed some minor issues here and there

 Changed: Global Handle to IPHLPAPI.DLL is now contained in the UDF and used to speed up function calls

 Misc. Other fixes I didn't keep track of!

See 1st post, which is now a bit more detailed


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By argumentum
      In the ZIP is the code and the compiled script.
      This is yet another ping the LAN utility.
      Is quite fast, as gathering the info. is forked.
      The Save Note, saves a note for the given MAC ( you may find it handy )
      The Save MACs, saves the listview to an INI file that can be later use for the WakeOnLAN
      Right click will bring a context menu to do stuff. DClick will refresh the Ping.
      That's it. Comes in handy to have in the USB toolbox  
    • By YogendraAtluri
      Hi, 
      I am new to AutoIT scripting and I am still learning. I am trying to communicate with a Labview application that acts like a server. it basically takes commands from the client. But for some commands, it also send back some data. 
      When i am sending commands from my script, i can see that the labview is getting them. But i am not able to get anything back. I tried different code pieces that are available online in the forum.
      This is the working piece of code which i been using to send data.
      #cs This module is used to establish tcp connection with lab view #ce #include <File.au3> Func SendCmd($cmd) TCPStartup() Local $IpAddress="192.168.10.101" Local $Port="5353" $Labview = TCPConnect($IpAddress,$Port) If @error Then ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ).' & @CRLF) TCPCloseSocket($Labview) TCPShutdown() Exit EndIf TCPSend($Labview, $cmd & @CRLF) TCPCloseSocket($Labview) TCPShutdown() EndFunc SendCmd("wt42d")  
      This is slightly modified code to send and receive data, which is not working. I am not getting any response back
      SendCmd("galil") Func SendCmd($cmd) TCPStartup() Local $IpAddress="192.168.10.101" Local $Port="5353" $Labview = TCPConnect($IpAddress,$Port) If @error Then ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ).' & @CRLF) TCPCloseSocket($Labview) TCPShutdown() Exit EndIf TCPSend($Labview, $cmd & @CRLF) $ip = @IPAddress1 ;create listening socket $Listensocket = TCPListen($ip, $Port) ConsoleWrite("Listening to Socket - " & $Listensocket & @CRLF) If $Listensocket = -1 Then ConsoleWrite("Exiting..." & @CRLF) Exit EndIf ;Accept incoming clients and recieve info While 1 $connectedsocket = TCPAccept($Listensocket) ConsoleWrite("Connecting to Socket - " & $connectedsocket & "Error -" & @error & @CRLF) If $ConnectedSocket >= 0 Then $ip2 = TCPRecv($connectedsocket,1000000) EndIf WEnd TCPCloseSocket($connectedsocket) TCPCloseSocket($Labview) TCPShutdown() EndFunc I am not getting anything back. I am getting the following output in the console
      +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. Listening to Socket - 544 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 its going through that loop forever. i need to force stop it.
      But when i open putty and send the same command, i am getting response right away. 
      Can someone please help me with that.
      Thanks in advance
      Regards
      Yogendra
    • By Se7enstars
      New Modern Design UI in AutoIt in 118 line
      Please watch & like in Youtube: Link
      Full Source Code free: Link
       

    • By argumentum
      I can TCP/IP in AutoIt, hence, make a HTTP deamon. Now, how can I HTTPS to use SSL !??
      Well, Apache has this "mod_proxy.so" module that can let me have SSL and what not is in Apache.
      All that is needed is to tell Apache what I wanna do by editing httpd.conf .
      # Implements a proxy/gateway for Apache. # 1. Open /Applications/XAMPP/etc/httpd.conf # 2. Enable the following Modules by removing the # at the front of the line. # - LoadModule rewrite_module modules/mod_rewrite.so # - LoadModule proxy_module modules/mod_proxy.so # - LoadModule proxy_http_module modules/mod_proxy_http.so # # 3. Copy and Paste below to the bottom of httpd.conf # <IfModule mod_proxy.c> ProxyRequests On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyVia Off ProxyPreserveHost Off ProxyPass /home/ http://127.0.0.1:84/home/ ProxyPassReverse /home/ http://127.0.0.1:84/home/ SetEnv proxy-nokeepalive 1 # ..since we are not using "keep-alive", we are using "close" </IfModule> ...et voila  
      I'm using XAMPP ( https://www.apachefriends.org/download.html )
      and this is my solution to avoid coding in PHP, as I feel more comfortable coding in AutoIt.
      A "muli-thread or concurrency" can be done by forking the socket ( https://www.autoitscript.com/forum/topic/199177-fork-udf-ish/ )
      but responses are under 20 ms., so I feel fine with a single thread.
      I modified an example ( attached below ), so can try out the concept.
      PS: I am not an Apache guru. I just discovered this and it opens a world of possibilities. In my case, I'm thinking of an API to query SQLite 
      PS2: I'm not gonna make Poll but do click like if you do  
       
      201673-json-http-post-serverlistener.au3
    • By _Vlad
      Hello forum,
      I want to create a program with multiple menus and many elements inside. The problem is my way of doing this and below I have an example of how I do these menus.
      I know it's a bad way of doing them as using this method for more elements and menus cause big flickering.
       
      Can someone please help me with some tips of optimizing this or tell me another way of creating that menus with many elements without cause flickering? From a long time ago I still try to solve this but without any results, just small improvements.
      Many thanks for everyone.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $MENU_HOVER = '' Global $MENU_SELECTED = '' Global $COLOR_STANDARD = 0x94A5E9 Global $COLOR_HOVER = 0x8292d1 Global $COLOR_SELECTED = 0x7584bf $MENU = GUICreate("Menu", 615, 437, -1, -1, -1, -1, 0) GUISetFont(10, 400, 0, "Arial") $MENU_1 = GUICtrlCreateLabel("Menu 1", 8, 24, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE)) $MENU_2 = GUICtrlCreateLabel("Menu 2", 8, 56, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE)) $MENU_3 = GUICtrlCreateLabel("Menu 3", 8, 88, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ;MENU 1 ELEMENTS $MENU_1_ELEMENT_1 = GUICtrlCreateButton("Menu1 Button", 128, 24, 147, 25) ;MENU 2 ELEMENTS $MENU_2_ELEMENT_1 = GUICtrlCreateButton("Menu2 Button", 128, 24, 147, 25) $MENU_2_ELEMENT_2 = GUICtrlCreateLabel("Another element", 128, 64, 99, 20) _Design() _Hide_All() GUISetState(@SW_SHOW, $MENU) While 1 $Cursor = GUIGetCursorInfo($MENU) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MENU_1 _Previous_Selected_Cancel() $MENU_SELECTED = 'Menu1' GUICtrlSetBkColor($MENU_1, $COLOR_SELECTED) _Show('Menu1') Case $MENU_2 _Previous_Selected_Cancel() $MENU_SELECTED = 'Menu2' GUICtrlSetBkColor($MENU_2, $COLOR_SELECTED) _Show('Menu2') Case $MENU_3 _Previous_Selected_Cancel() $MENU_SELECTED = 'Menu3' GUICtrlSetBkColor($MENU_3, $COLOR_SELECTED) _Show('Menu3') EndSwitch If $Cursor[4] = $MENU_1 Then If $MENU_HOVER <> 'Menu1' And $MENU_SELECTED <> 'Menu1' Then _Previous_Hover_Cancel() GUICtrlSetBkColor($MENU_1, $COLOR_HOVER) $MENU_HOVER = 'Menu1' EndIf ElseIf $Cursor[4] = $MENU_2 Then If $MENU_HOVER <> 'Menu2' And $MENU_SELECTED <> 'Menu2' Then _Previous_Hover_Cancel() GUICtrlSetBkColor($MENU_2, $COLOR_HOVER) $MENU_HOVER = 'Menu2' EndIf ElseIf $Cursor[4] = $MENU_3 Then If $MENU_HOVER <> 'Menu3' And $MENU_SELECTED <> 'Menu3' Then _Previous_Hover_Cancel() GUICtrlSetBkColor($MENU_3, $COLOR_HOVER) $MENU_HOVER = 'Menu3' EndIf Else _Previous_Hover_Cancel() $MENU_HOVER = 'Idle' EndIf WEnd Func _Design() GUICtrlSetColor($MENU_1, 0xFFFFFF) GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD) GUICtrlSetCursor($MENU_1, 0) GUICtrlSetColor($MENU_2, 0xFFFFFF) GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD) GUICtrlSetCursor($MENU_2, 0) GUICtrlSetColor($MENU_3, 0xFFFFFF) GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD) GUICtrlSetCursor($MENU_3, 0) EndFunc ;==>_Design Func _Hide_All() GUICtrlSetState($MENU_1_ELEMENT_1, $GUI_HIDE) GUICtrlSetState($MENU_2_ELEMENT_1, $GUI_HIDE) GUICtrlSetState($MENU_2_ELEMENT_2, $GUI_HIDE) EndFunc ;==>_Hide_All Func _Show($MENU_SHOW) _Hide_All() If $MENU_SHOW = 'Menu1' Then GUICtrlSetState($MENU_1_ELEMENT_1, $GUI_SHOW) ElseIf $MENU_SHOW = 'Menu2' Then GUICtrlSetState($MENU_2_ELEMENT_1, $GUI_SHOW) GUICtrlSetState($MENU_2_ELEMENT_2, $GUI_SHOW) ElseIf $MENU_SHOW = 'Menu3' Then EndIf EndFunc ;==>_Show Func _Previous_Hover_Cancel() If $MENU_HOVER = 'Menu1' Then If $MENU_SELECTED <> 'Menu1' Then GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD) ElseIf $MENU_HOVER = 'Menu2' Then If $MENU_SELECTED <> 'Menu2' Then GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD) ElseIf $MENU_HOVER = 'Menu3' Then If $MENU_SELECTED <> 'Menu3' Then GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD) EndIf EndFunc ;==>_Previous_Hover_Cancel Func _Previous_Selected_Cancel() If $MENU_SELECTED = 'Menu1' Then GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD) If $MENU_SELECTED = 'Menu2' Then GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD) If $MENU_SELECTED = 'Menu3' Then GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD) EndFunc ;==>_Previous_Selected_Cancel  
×
×
  • Create New...