Jump to content

Recommended Posts

Hi guys,

I have a biiiiiiiiiiiig problem and i'll be happy if it was be solved,:sweating:

My question is :

If i use this file : "Client (32 Bit).exe" file , i can connect to "Server.exe",

But when ever i try to edit "Client.au3" file for my own,it can not connect to "Server.exe" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

==================================

              |         *Notes*         |

* "Server.exe" was in "VPS"

*Client (32 Bit).exe was attached.

*Client.au3 was attached.

*Server.exe was attached.

*Server.au3 was attached.

==================================

Client.au3 : 

#RequireAdmin
#Include <ButtonConstants.Au3>
#Include <EditConstants.Au3>
#Include <GUIConstantsEx.Au3>
#Include <StaticConstants.Au3>
#Include <WindowsConstants.Au3>
#Include <GUIEdit.Au3>
#Include <Misc.Au3>
;~ #NoTrayIcon

Opt ('GUIOnEventMode', 1)
TcpStartUp ()

Global $Server = -1, $Logs

$Settings = GUICreate ('Connection Settings', 180, 100, -1, -1, -1, 128)
GUISetOnEvent  ($GUI_EVENT_CLOSE, '_Exit')
GUICtrlCreateGroup  ('', 5, 0, 170, 94)
$IP = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','IP',0), 12, 13, 100, 21, 1)
$Port = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','Port',0), 117, 13, 50, 21, 1)
$User = GUICtrlCreateInput (IniRead ('Settings.ini','Settings','User',0), 12, 39, 156, 21, 1)
$Connect = GUICtrlCreateButton ('Connect', 12, 66, 100, 20, $WS_GROUP)
GUICtrlSetOnEvent ($Connect, '_Start')
$Exit = GUICtrlCreateButton ('Exit', 117, 66, 50, 20, $WS_GROUP)
GUICtrlSetOnEvent ($Exit, '_Exit')
GUISetState (@SW_SHOW)
WinSetOnTop ($Settings, '', 1)

$GUI = GUICreate ('TCP Chat Room', 375, 275, -1, -1, -1, 128)
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Toggle')
$History = GUICtrlCreateEdit ('', 0, 1, 375, 203, 2103360 + $ES_MULTILINE)
GUICtrlSetFont ($History, 10, -1, -1, 'Lucida Sans Unicode')
GUICtrlSetBkColor ($History, 0x83B4FC)
GUICtrlSetColor ($History, 0xFFFFFF)
$Send = GUICtrlCreateEdit ('', 0, 205, 375, 70, 2101248)
GUICtrlSetFont ($Send, 10, -1, -1, 'Lucida Sans Unicode')
GUICtrlSetColor ($Send, 0x83B4FC)
GUISetState (@SW_HIDE)

While 1
    Sleep (15)
    If $Server <> -1 Then
        $Recv = TcpRecv ($Server, 1000000)
        If @Error Then
            GUISetState (@SW_HIDE, $GUI)
            WinSetOnTop ($GUI, '', 0)
            Sleep (100)
            MsgBox (48, 'Server Notice','You have been disconnected from the server.')
            _Disconnect ()
        EndIf
        If $Recv = 'Error:Username.Exists;' Then
            GUISetState (@SW_HIDE, $GUI)
            WinSetOnTop ($GUI, '', 0)
            Sleep (100)
            MsgBox (48, 'Server Notice','Your username is already in use, please change it and try again.')
            _Disconnect ()
        ElseIf $Recv = 'Error:Max.Connections;' Then
            GUISetState (@SW_HIDE, $GUI)
            WinSetOnTop ($GUI, '', 0)
            Sleep (100)
            MsgBox (48, 'Server Notice','Max amount of connections reached, try again later.')
            _Disconnect ()
        ElseIf $Recv = 'Error:IP.Banned;' Then
            GUISetState (@SW_HIDE, $GUI)
            WinSetOnTop ($GUI, '', 0)
            Sleep (100)
            MsgBox (48, 'Server Notice','Your IP address has been banned.')
            _Disconnect ()
        ElseIf StringLeft ($Recv, 4) = '.log' Then
            FileWriteLine ('Logged.txt', StringTrimLeft ($Recv, 5))
        ElseIf $Recv <> '' Then
            _Log (StringReplace ($Recv, '%Time', @HOUR & ':' & @MIN))
        EndIf
        If _IsPressed ('0D') And GUICtrlRead ($Send) <> '' And ControlGetFocus ($GUI) = 'Edit2' Then
            $Read = StringReplace (GUICtrlRead ($Send), @CRLF, '')
            $Read = StringReplace ($Read, @CR, '')
            $Read = StringReplace ($Read, @LF, '')
            If $Read = '.clear' Then
                GUICtrlSetData ($History, '')
            ElseIf $Read = '.logs' Then
                _Logs ()
            ElseIf $Read = '.save' Then
                FileWrite (@MDAY & '-' & @MON & '-' & @YEAR & '_' & @HOUR & '-' & @MIN & '-' & @SEC & '_Logs.txt', GUICtrlRead ($History))
            ElseIf $Read = '.disconnect' Or $Read = '.exit' Then
                _Disconnect ()
            Else
                TcpSend ($Server, $Read)
            EndIf
            GUICtrlSetData ($Send, '')
        EndIf
    EndIf
WEnd

Func _Logs ()
    $Logs = GUICreate ('Admin Logs', 375, 203, -1, -1, -1, 128)
    GUISetOnEvent ($GUI_EVENT_CLOSE, '_Delete')
    $Edit = GUICtrlCreateEdit ('', 0, 1, 375, 203, 2103360 + $ES_MULTILINE)
    GUICtrlSetFont ($Edit, 10, -1, -1, 'Lucida Sans Unicode')
    GUICtrlSetBkColor ($Edit, 0x83B4FC)
    GUICtrlSetColor ($Edit, 0xFFFFFF)
    GUISetState (@SW_SHOW)
    GUICtrlSetData ($Edit, FileRead ('Logged.txt'))
    WinSetOnTop ($Logs, '', 1)
EndFunc

Func _Delete ()
    GUIDelete ($Logs)
EndFunc

Func _Disconnect ()
    GUICtrlSetData ($History, '')
    TcpCloseSocket ($Server)
    $Server = -1
    GUISetState (@SW_HIDE, $GUI)
    WinSetOnTop ($GUI, '', 0)
    GUISetState (@SW_SHOW, $Settings)
    WinSetOnTop ($Settings, '', 1)
EndFunc

Func _Toggle ()
    GUICtrlSetData ($History, '')
    TcpCloseSocket ($Server)
    $Server = -1
    GUISetState (@SW_HIDE, $GUI)
    WinSetOnTop ($GUI, '', 0)
    GUISetState (@SW_SHOW, $Settings)
    WinSetOnTop ($Settings, '', 1)
EndFunc

Func _Log ($Data)
    GUICtrlSetData ($History, GUICtrlRead ($History) & $Data & @CRLF)
    _GUICtrlEdit_LineScroll ($History, 0, _GUICtrlEdit_GetLineCount ($History) - 1)
EndFunc

Func _Start ()
    If GUICtrlRead ($User) == '' Or GUICtrlRead ($IP) == '' Or GUICtrlRead ($Port) == '' Then Return @Error
    $Server = TcpConnect (GUICtrlRead ($IP), GUICtrlRead ($Port))
    If $Server = -1 Or @Error Then
        WinSetOnTop ($Settings, '', 0)
        Sleep (100)
        MsgBox (16, 'Fatal Error','Unable to connect to the server, change your settings and try again.')
        WinSetOnTop ($Settings, '', 1)
        Return @Error
    EndIf
    Sleep (150)
    TcpSend ($Server, GUICtrlRead ($User))
    GUISetState (@SW_HIDE, $Settings)
    WinSetOnTop ($Settings, '', 0)
    GUISetState (@SW_SHOW, $GUI)
    WinSetOnTop ($GUI, '', 1)
EndFunc

Func _Exit ()
    IniWrite ('Settings.ini','Settings','IP', GUICtrlRead ($IP))
    IniWrite ('Settings.ini','Settings','Port', GUICtrlRead ($Port))
    IniWrite ('Settings.ini','Settings','User', GUICtrlRead ($User))
    Exit
EndFunc

==================================

I use this UDF Example : 

Thanks and i really need your helps :(

Client (32 Bit).exe

Client.au3

Server.au3

Server (32 Bit).exe

Edited by zxtnt09
File Attached
Link to comment
Share on other sites

  • Moderators

zxtnt09,

You have been here long enough to know not to bump your own threads within 24 hours.

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare.  You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online.  Be patient and someone will answer eventually.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

zxtnt09,

You have been here long enough to know not to bump your own threads within 24 hours.

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare.  You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online.  Be patient and someone will answer eventually.

M23

14 Hours != 24 :(

i'm so sorry Sorry,

i really need to know that, why this exe file is not similar source file,

all of those run , but "compiled" file ( from autor ) is fixed, but if i try to compile that, not connect to server... !!!!

and it is so strange for me :'(

Link to comment
Share on other sites

Looks a bit odd to me at first glance, since the error you are getting comes from within a function which appears never to be even called.

Searched "_Start "  instead of "_Start"

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Looks a bit odd to me at first glance, since the error you are getting comes from within a function which appears never to be even called.

And what is that meant ?1 :( 

i don't know why and how to fix that,

all of those source code ( maybe i think ) is same,

but i can just run that "Client (32 bit).exe" and i can not modify "Client.au3"

 

 

Link to comment
Share on other sites

Change this code...

If $Server = -1 Or @Error Then
        WinSetOnTop ($Settings, '', 0)
        Sleep (100)
        MsgBox (16, 'Fatal Error','Unable to connect to the server, change your settings and try again.')
        WinSetOnTop ($Settings, '', 1)
        Return @Error
    EndIf

To this code...

If $Server = -1 Or @Error Then

        $iError = @error
        WinSetOnTop ($Settings, '', 0)
        Sleep (100)
        MsgBox (16, 'Fatal Error','Unable to connect to the server, change your settings and try again.' & @crlf & 'Error: ' & $iError)
        WinSetOnTop ($Settings, '', 1)
        Return @Error
    EndIf

Show your error

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

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.
    See connect timeout example.

 

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

 

 

If use this , 

#include <MsgBoxConstants.au3>

; I am the client, start me after the server no more than 10sec ! (The server script is the TCPAccept example script).

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    Opt("TCPTimeout", 1000)
    Local $nMaxTimeout = 10 ; script will abort if no server available after 10 secondes

    Local $iSocket, $iError

    While 1
        ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified.
        $iSocket = TCPConnect($sIPAddress, $iPort)

        ; If an error occurred display the error code and return False.
        If @error = 10060 Then
            ; Timeout occurs try again
            $nMaxTimeout -= 1
            If $nMaxTimeout < 0 Then
                MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, after " & 10 - $nMaxTimeout & " TimeOut")
                Return False
            EndIf
            ContinueLoop
        ElseIf @error Then
            $iError = @error
            ; The server is probably offline/port is not opened on the server.
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, Error code: " & $iError)
            Return False
        Else
            MsgBox($MB_SYSTEMMODAL, "", "Connection successful after " & 10 - $nMaxTimeout & " TimeOut")
            ExitLoop
        EndIf

    WEnd

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

The connections goes true !,

1 ) thank you i think it's true :wub:

2 ) now what should i added in my client script :sweating:

===================================================

Answer : i should add this : 

Opt("TCPTimeout", 1000)

but question : 

when i use that, my scirpt was lagged and slow !!!!

============================

[Solved] a : i should set that to "0", 

Opt("TCPTimeout", 0)

..........

sp thanks to @JohnOne :wub:

Edited by zxtnt09
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...