Jump to content

Recommended Posts

Nice tutorial. You should probably look at using variable declaration in your examples. For example your Global declaration should be Local as the variable isn't used anywhere else but in Local scope.


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

server is already set to handle more than 1 connection, you just need to:

get rid of msgbox (use gui commands instead) that pause server

limit if needed numebr of connection that it will handle

change how and when will server disconnect clients

Read server part with explained code for more info.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Thanks for the code and tutorial, helpful codes. let me start by saying i am a beginner, so please don't laugh too at my questions!

1. with your codes, I have to run the server and client codes on every PC connected on my network. is there a possibility that I might run the codes for server just once and on the other PCs, i will just have to run but the codes for clients?

2. I wish to have 3 or more Computers, the first computer is my master, where my server runs, the other computers are my client. I wish to send message in both dirrection via TCP as is the case with your codes how am I going to do it?

3. I have tried to open TCP socket via internet but all my attemps have failed. my internet IPaddress is 192.168.1.1

I will be grateful if you find time and provide me some helps.

Best regards

Hubert

Share this post


Link to post
Share on other sites

Guess i need to add litle more info about networks on first post

lets expalind it heare like this

I have 2 computers and i need to do TCP over wireless network.

My first computer (he will be server) need to lissen on my second adapter (my first adapter is lan, my second adapter is wireless card), he (wirelles card) is with IP adress @IPAddress2 or 192.168.0.1 (@IPAddress2 is my wireless adapter IP that i manyaly tuped on adapter)

my second computer that have only client on him is with ip address 192.168.0.2 on his wireless lan card and he is connected over that card to my wireless card so that we can be in network, but his IP is not important cos i only need to know server IP adress 192.168.0.1 so that i can connect on him.

so on server im starting it with

$Listen = TCPListen(@IPAddress2, 1018, 500)

or with $Listen = TCPListen('192.168.0.1', 1018, 500), it is identical cos @IPAddress2 will return (in my case) IP address of my second device 192.168.0.1

and on client script im putting

$Socket = TCPConnect('192.168.0.1', 1018)

so im connection on IP adress of server with client

now let's say that i wanna connect more than one pc but not on my wireless network cos it accept only 2 computers, i wanna do it on lan network adapter (my first lan device), on lan i have 6 PC-s connected on network.

My first comp is with ip adress lets say 10.0.252.30 on my local area connection adapter.

How can i confirm that my ip is 10.0.252.30?! From start meny i sellect run (or in win 7 just tupe cmd and hit enter with no run) tupe in cmd and press enter. after that in cmd i type in ipconfig and press enter.

it will list all of your adapters and their ip (IPv4) addresses.

So im gona start server on my network lan adapter

$Listen = TCPListen('10.0.252.30', 1018, 500)

and every client i connect on him will connect to that ip adress

so on client im dooing this

$Socket = TCPConnect('10.0.252.30', 1018)

So i will connect more than one client and only one comp (my first comp) will serve as my server.

Note that somethimes firewall can cose problems, so if you have problems turn it off to see if it will work.

As for internet communication i can't help a lot, i never tried coz my ports are forwarded. Main thing i know is if your behind router form your ISP and your ports arn't forwarded you need to call your ISP on the phone and to tell him to forward that darn port and don't hang up till he say "ok i forwarded it".

If router is in your controll, don't call ISP, take a look at this videos (they are nice tytorials)

and do it yourself ;)

here you can check if others can see you on that port

http://www.yougetsignal.com/tools/open-ports/

or

http://www.canyouseeme.org/

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Thank you bogQ for this terrific tutorial!

The time you put into this is very much appreciated!

Great work!

Would you be okay with taking this to the next level?

-Adding GUI instead of Msgbox

-Having one script work as both server and client to create an Instant Messaging program

-Adding Contact List of all machines that are connected (listed as IP address or @ComputerName

This would probably be a big project, but written in the style that you have already done would be of great help.

I figure it never hurts to ask and certainly you've given us a great base of understanding to work from.

Thank you again!

Edited by coffeeturtle

Share this post


Link to post
Share on other sites

Thnx for your helpful topic.

I have a question though. I would like to use TCP to connect (lets say) 2 computers but in different houses. So different IP adresses.

So the connection should go via WAN, not LAN. How can I make my real IP adress, like 77.170.181.98, serve as a server?

Thnx in advance :)

Share this post


Link to post
Share on other sites

Guess someone with more experience with internet communication should answer this one but if im wrong they can still correct me or at least confirm if this is correct :P (as i stated before "i can't help a lot, i never tried coz my ports are forwarded")

So "if im not wrong",

one computer is server, his public IP address is 77.170.181.98

one client, we dont need to know his ip adress, but he need to know server public IP address.

Server TCPListen on his addapter IP adress (so that isnt 77.170.181.98, we need adapter address) (port must be forwarded on router)

Client connect to 77.170.181.98 server public IP adress.

So client try to connect to server

*Client send msg to server ip adress

77.170.181.98:8080 -> "are you there?"

*router recive msg for port 8080 and forward it on that port to your listening device 10.0.252.30

->77.170.181.98:8080 -> 10.0.252.30:8080 -> "are you there?"

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

that's basically how it works. i just use TCPListen("0.0.0.0", 8080) and it automatically listens on your default adaptor. no need to even get lan/wan ip on the server.

on the router, forward 8080 to your local server ip.

on the client, connect to the servers WAN.

or use @IPAddress1 instead of 0.0.0.0. either should work fine.

edit: 0.0.0.0 makes it listen on "any available" ip, so it will work with multiple adaptoras, i believe.

Edited by caleb41610

Share this post


Link to post
Share on other sites

Ok thnx for the info.

It is still not working though.

This is a picture of the port I forwarded (is this right??):

Posted Image

And then this is the server script line:

$Listen = TCPListen('192.168.2.8', 8080, 500)

And this is the client's line:

$Socket = TCPConnect('77.170.181.98', 8080)

This should be good, right?

It is not working though, please tell me if I did something wrong

Share this post


Link to post
Share on other sites

as i told my isp did not forwarded my ports so i can test

in theory it should work

i posted 2 links in first post

http://www.yougetsignal.com/tools/open-ports/

or

http://www.canyouseeme.org/

so can they see you on port 8080?

another question is , is your port 8080 free? no other program is using him?

did you try on some other port? is your wirewall off?


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Ok thnx for the info.

It is still not working though.

This is a picture of the port I forwarded (is this right??):

Posted Image

And then this is the server script line:

$Listen = TCPListen('192.168.2.8', 8080, 500)

And this is the client's line:

$Socket = TCPConnect('77.170.181.98', 8080)

This should be good, right?

It is not working though, please tell me if I did something wrong

You must also open the port in your firewall.

Share this post


Link to post
Share on other sites

Ok still now working.

I changed to port 8081 (just to be sure the port wasn't used by anything else)

I also opened 8081 on my windows firewall.

I checked with the port website, and it says the port is open (if the server is running):

As you see, the port is open.Posted Image

Now when I run the client, I get the following error:

!--> TCPConnect error number ( 10060 ), look in the help file (on MSDN link) on func TCPConnect to get more info about this error.

BTW: I'm running the client and server on the same pc (thus same ip adress). Could this be causing my trouble?

I've been trying to make this work for ages now, please help me out once more!

Thnx :)

Edited by ludocus

Share this post


Link to post
Share on other sites

yes it can, if you ever had experience with wamp server or wow servers for example, you couldn't never connect to the site or gameserver on internet connection ip adress from the computer that is running that server, but you can go to that adress if you go to some proxy with browser site and connecting with it with no problems.

so

WSAETIMEDOUT 10060

Connection timed out.

A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond.

can be cuz of that, and in addition it can be cuz of port problem, or something third.

So please do try to connect with 2 different computers with 2 different internet connection on them. (call some friend and tell him to run your client)

if it dont work try some other random ports eg 3724 8129 28960...

and try to lisssen on ip 0.0.0.0

for some other info to "can it realy work" you can look at this post to see that TCP do work on internet if everything is configyred in the correct way and your isp isnt playing with you.

http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

just a quick note from my side, after i convince my isp to geave me some free ports for next month, i tryed to connect over internet on port 8080 today to test do it work or not

tcp lisen on 0.0.0.0 and after that on @IPAddress1 with port 8080, connected to server public IP and message recived, sended, and recived with no problems

port 80 did have probably cos my wamp did use it when i try it on.

So it do work with no problem if everything is configured correctly.


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Excellent. This was exactly what I needed.

I have another script I'm building that's generating text output. I wanted to be able to call a separate script running a TCP server, pass the data over Stdin, and have the Server duplicate out whatever data is was sent to whatever clients are connected at the time, and manage listening, opening, and closing Sockets.

I have something like this compiled to .EXE, though if running as an .au3 file, it will prompt you with an Input box for data to send. Connect and disconnect as many Telnet (Putty, Teraterm) sessions as you want and they start getting output.

 

#include <Array.au3>
#include <WinAPIProc.au3>
;Ref https://www.autoitscript.com/forum/topic/144987-learning-about-tcp-servers-and-clients-connection/
    $ParentPID = _WinAPI_GetParentProcess()
TCPStartup()
OnAutoItExitRegister("OnAutoItExit")
    Dim $Socket_Data[1]
$Socket_Data[0] = 0
$Listen = TCPListen("0.0.0.0", 1018, 500)
If @error Then
    ConsoleWrite('!--> TCPListen error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPListen to get more info about this error.' & @CRLF)
    Exit
EndIf
    While ProcessExists($ParentPID)
    If @Compiled=0 Then
        $TCPdata=InputBox("TCPServer","Type Data to send")
    Else
        $TCPData = ConsoleRead()
        EndIf
        If StringLen($TCPData) > 0 Then
        For $x = $Socket_Data[0] To 1 Step -1
            TCPSend($Socket_Data[$x], $TCPData)
            If @error Then
                _CloseConnection()
            EndIf
        Next
    EndIf
    _Accept()
    Sleep(500)
WEnd
    Func _Accept()
    Local $Accept = TCPAccept($Listen)
    If $Accept <> -1 Then
        _ArrayAdd($Socket_Data, $Accept)
        $Socket_Data[0] += 1
    EndIf
EndFunc   ;==>_Accept
    Func _CloseConnection()
    _ArrayDelete($Socket_Data, $x)
    $Socket_Data[0] -= 1
EndFunc   ;==>_CloseConnection
    Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

    I then use this script to establish the link to Stdin:
     

    #include <AutoItConstants.au3>
$iPID = Run("tcpserver.exe", "", @SW_HIDE, $STDIN_CHILD)
While 1
    $Data=InputBox("Input","data")
    StdinWrite($iPID,$Data)
Wend
   

 

Edited by TurionAltec

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

  • Similar Content

    • By AoRaToS
      I started working on this program in the summer then I stopped cause I faced some problems I couldn't overcome back then. Now that I've practiced more and have become a better scripter/programmer I'm releasing the program to the public to get some opinions. I know it's not a new concept but it's the first program I started besides some small stuff I did just for practice! I won't post the source code yet because it's still under construction, although I'm sure I've posted early stages of the code with bugs in the past in some topic...
      What I wanted was a simple, small, serverless program that would work without installation cause I wanted it for where I work, so I ended up with this!
       
      I have attached some images of various versions, also visit the forum thread.
       
      The package includes s!mpL3 LAN Messenger, the License Agreement and the change log.
       
      Current version 2.9.9.0! [13/06/2019]
       
      Check the Change Log below!
       
       
      http://www.autoitscript.com/forum/index.php?showtopic=88782
       
       
       
      Read the license before using this software.
       
    • By Colduction
      Hello Guys and AutoIt Scriptwriters!🎉❤️
      I've created a script to notify to me if RDP main IP changed then send a message via Telegram bot to me
      But some of my RDP's Main IP are @IPAddress1 or @IPAddress3 or Public IP Address...
      I want to detect automatically the IP that windows client can run RDP to remotely control
      This image can help you that what i say, there are three RDP with specified IP, i want to run script in these RDP's then capture those IP's changes then notify me via Telegram bot

    • By rudi
      Hello,
      When new versions e.g. of your compiled script cannot be replaced on the server, as they are in use, you can use this script to manage to close the open handles and to replace the old file with your new version.

      ; Autoit v3.3.14.5 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Description=Close OpenFileHandlles, replace file on Server with a new version #AutoIt3Wrapper_Res_Fileversion=1 #AutoIt3Wrapper_Res_LegalCopyright=(c) 2019 by Rudolf Thilo, IT-Beratung Rudolf Thilo #AutoIt3Wrapper_Res_SaveSource=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <NetShare.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <EditConstants.au3> ; Enumerate open files on the server $DragDropOpenFile = "<drag-drop file locked on Server to be closed and replaced>" $DragDropNewFile = "<drag-drop file to replace the one on the server>" $NewFile = "" $Gui_h = 250 $Gui_w = 800 $vDist = 7 ; GUICreate($GuiTitle, $w, $h, @DesktopWidth - $w - 100, @DesktopHeight - $h - 60, -1, $WS_EX_ACCEPTFILES) ; generally enable drag-drop for files into other GUI controls $myGui = GUICreate("force close of all NETWORK opened file handles", $Gui_w, $Gui_h, 100, 100, -1, $WS_EX_ACCEPTFILES) $InputFileToClose = GUICtrlCreateInput($DragDropOpenFile, 20, $vDist, $Gui_w - 40, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; allow drag-droping files for this control, $InputFile Opt("Guicoordmode", 2) $InputFileNew = GUICtrlCreateInput($DragDropNewFile, -1, $vDist) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; allow drag-droping files for this control, $InputFile GUICtrlSetState(-1, $GUI_DISABLE) $lServer = GUICtrlCreateLabel("<server>", -1, $vDist) $lShare = GUICtrlCreateLabel("<share>", -1, $vDist) $lPath = GUICtrlCreateLabel("<path>", -1, $vDist) $lFile = GUICtrlCreateLabel("<file>", -1, $vDist) $doit = GUICtrlCreateButton("search for and close open file handles", -1, $vDist) GUICtrlSetState(-1, $GUI_DISABLE) $exit = GUICtrlCreateButton("cancel", -1, $vDist) GUISetState() $FN = False $FNnew = "" $FNmatch = False $ToolTitle = "" $ToolTxt = "" While 1 $input = GUICtrlRead($InputFileToClose) If $input <> $DragDropOpenFile Then ; da wurde was reingezogen $DragDropOpenFile = $input If StringLeft($input, 2) = "\\" Then $Type = "UNC" $ServerShareUNC = StringLeft($input, StringInStr($input, "\", 0, 4) - 1) $fRelPathFN = StringReplace($input, $ServerShareUNC, "") $fPath = StringLeft($fRelPathFN, StringInStr($fRelPathFN, "\", 0, -1)) $FN = StringTrimLeft($fRelPathFN, StringInStr($fRelPathFN, "\", 0, -1)) ElseIf StringMid($input, 2, 1) = ":" Then ; Pfad mit Laufwerksbuchstabe, evtl. Netzwerk Mapping (erforderlich) $drive = StringLeft($input, 2) $Type = DriveGetType($drive) If $Type = "Network" Then $ServerShareUNC = DriveMapGet($drive) $foo = StringReplace($input, $drive, $ServerShareUNC) ; Laufwerkspfad in UNC Pfad umwandeln $fRelPathFN = StringReplace($foo, $ServerShareUNC, "") $fPath = StringLeft($fRelPathFN, StringInStr($fRelPathFN, "\", 0, -1)) $FN = StringTrimLeft($fRelPathFN, StringInStr($fRelPathFN, "\", 0, -1)) Else MsgBox(0, @ScriptLineNumber, "This script can *ONLY* close open file handles on NETWORK SHARES!" & @CRLF & _ $input & @CRLF & _ $drive & " = " & $Type) ContinueLoop 2 EndIf EndIf $Server = StringLeft($ServerShareUNC, StringInStr($ServerShareUNC, "\", 0, 3) - 1) $Share = StringTrimLeft($ServerShareUNC, StringInStr($ServerShareUNC, "\", 0, 3) - 1) GUICtrlSetData($lServer, $Server) GUICtrlSetData($lShare, $Share) GUICtrlSetData($lPath, $fPath) GUICtrlSetData($lFile, $FN) GUICtrlSetState($doit, $GUI_ENABLE) GUICtrlSetState($InputFileNew, $GUI_ENABLE) EndIf If $NewFile <> GUICtrlRead($InputFileNew) Then $NewFile = GUICtrlRead($InputFileNew) If $NewFile <> $DragDropNewFile Then If StringInStr($NewFile, $DragDropNewFile) Then $NewFile = StringReplace($NewFile, $DragDropNewFile, "") GUICtrlSetData($InputFileNew, $NewFile) EndIf $FNnew = StringTrimLeft($NewFile, StringInStr($NewFile, "\", 0, -1)) If $FN = $FNnew Then If $FNmatch = False Then $FNmatch = True GUICtrlSetData($doit, "Search for open file handles, close them, overwrite old file.") EndIf Else If $FNmatch Then $FNmatch = False GUICtrlSetData($doit, "Search for open file handles and close them.") GUICtrlSetData($InputFileNew,$DragDropNewFile) EndIf EndIf EndIf EndIf Switch GUIGetMsg() Case $exit, $GUI_EVENT_CLOSE GUIDelete($myGui) Exit Case $doit AbArbeiten($Server, $Share, $fPath, $FN) EndSwitch WEnd Func AbArbeiten($_Srv, $_Shr, $_fPth, $_fNme) Local $iID = 0 Local $iRights = 1 Local $iLckCount = 2 Local $iFPFN = 3 Local $iUser = 4 ConsoleWrite($_fPth & $_fNme & @CRLF) Local $aFile = _Net_Share_FileEnum($_Srv) If IsArray($aFile) Then ; _ArrayDisplay($aFile) Local $x $ToolTxt = "Open Handles:" $ToolTitle = $aFile[0][0] & " handles still waiting to be checkt..." UpdateToolTip() AdlibRegister(UpdateToolTip, 1000) For $x = $aFile[0][0] To 1 Step -1 $ToolTitle = $x & " handles waiting to be checked..." If Not StringInStr($aFile[$x][$iFPFN], $_fPth & $_fNme) Then ; ConsoleWrite("Nix Enthalten in: " & $aFile[$x][$iFPFN] & @CRLF) _ArrayDelete($aFile, $x) Else $ToolTxt &= @CRLF & $aFile[$x][$iFPFN] & ", User = " & $aFile[$x][$iUser] ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ToolTxt = ' & $ToolTxt & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console EndIf Next $aFile[0][0] = UBound($aFile) - 1 _ArraySort($aFile, 0, 1, 0, $iUser) ; _ArrayDisplay($aFile, $aFile[0][0] & " FileLocks found.") If $aFile[0][0] = 0 Then $ToolTitle = "Done. No open handles coud be found." $ToolTxt &= @CRLF & "Nothing to be closed!" Sleep(2000) $ToolTxt = "" Else $ToolTitle = $aFile[0][0] & " Handles found to be closed..." $CloseErr = 0 For $x = 1 To $aFile[0][0] If _Net_Share_FileClose($Server, $aFile[$x][$iID]) Then $ToolTxt &= @CRLF & @TAB & "Handle closed: " & $aFile[$x][$iID] Else $ToolTxt &= @CRLF & "ERROR: Handle Close Failed! --> " & $aFile[$x][$iFPFN] & ", User = " & $aFile[$x][$iUser] $CloseErr += 1 EndIf Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $CloseErr = ' & $CloseErr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console If $CloseErr = 0 Then $ToolTitle = "Alle open handles were closed successfully." If FileExists($NewFile) Then If FileCopy($NewFile, $input, 1 + 8) Then $ToolTitle = "File could be replaced." $ToolTxt = "done" Else $ToolTitle = "File could *NOT* be replaced" $ToolTxt = "Most propably a newly open file handle was created while this script was running." & @CRLF & _ "Just start over again." EndIf EndIf Else $ToolTitle = $CloseErr & " handles could *NOT* be closed!" Sleep(2000) EndIf Sleep(1000) $ToolTxt = "" $ToolTitle = "" EndIf Else MsgBox(0, "not an array", $aFile & @CRLF & @error & @CRLF & @extended) EndIf EndFunc ;==>AbArbeiten Func UpdateToolTip() ToolTip($ToolTxt, MouseGetPos(0) + 20, MouseGetPos(1) + 20, $ToolTitle) ; ConsoleWrite( $ToolTxt & @CRLF & $ToolTitle & @CRLF & "-------------------" & @CRLF) EndFunc ;==>UpdateToolTip Rudi.
    • By HansHenrik
      ----------
      edit: this is probably in the wrong place, can a moderator move it to wherever it belongs?
      ----------

      is there any way to completely disable TCPTimeout and make TCPRecv() wait indefinitely? maybe setting it to 0 or -1 or something? 
      the docs doesn't seem to mention any way to disable it

      - the underlying C code would set SO_RCVTIMEO to 0 , aka

      DWORD timeout=0;
      setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
    • By Spartan117
      Hi everyone,
      I wonder if there is a cloud service that can offer a physical server so that AutoIT can turn as it is in a physical machine.
      Thank you
×
×
  • Create New...