Sign in to follow this  
Followers 0
WSCPorts

Had to add Dim statements to tcp _cs_ Server

2 posts in this topic

although they are ver minor edits i guess window 2003 require more strictness because i tried to set (opt "MustDeclareVars", 0) to no avail so i modified it it might not work with the client yet.... :/me work on that to in 3.1.1.62

New

; Modified by CyberSlug - 30 Jan 2005
; but 99% of the credit belongs to Larry!
Dim $MainSocket[2]
;SERVER!! Start Me First !!!!!!!!!!!!!!!
#include <GUIConstants.au3>

HotKeySet("#q", "Quit")
Func Quit()
    Exit
EndFunc

DLLCall("betaau3xtra.dll","int","TCPStartUp")

$MainSocket[0] = DLLCall("betaau3xtra.dll", "int", "TCPListen", "str", "127.0.0.1", "int", 65432, "int", 0 )


Dim $socket[1]
$socket[0] = 0

Global $g_msg = ">"
Global $msg

$GOOEY = GUICreate("my server",300,200)
$edit = GUICtrlCreateEdit("Press Win+Q to Quit Server!!!",10,40,200,150,$WS_DISABLED)
$input = GUICtrlCreateInput("",10,10,200,20)
$butt = GUICtrlCreateButton("Send",210,10,80,20,$BS_DEFPUSHBUTTON)
GUISetState()

While 1
    GuiCtrlSetData($input, @HOUR & ":" & @MIN & ":" & @SEC)
   $msg = $butt
   sleep(1000)


   If $msg = $GUI_EVENT_CLOSE Then
      GUIDelete($GOOEY)
      ExitLoop
   EndIf
   If $msg = $butt Then
      Proc(GUICtrlRead($input))
      GUICtrlSetData($input,"")
       If $socket[0] > 0 Then
          For $i = 1 to UBound($socket) - 1
              If $i < UBound($socket) Then 
                Dim $ret[0]
                  $ret[0] = DLLCall( "betaau3xtra.dll", "int", "TCPSend", "int", $socket[$i], "str", $g_msg)
                 If $ret[0] < 0 Then
                    RemoveSocket($socket,$i)
                    ContinueLoop
                 EndIf
                 
                 
                $ret[0] = DLLCall("betaau3xtra.dll","int","TCPRecv", "int", $socket[$i], "str", "", "int", 512 )
                 If $ret[0] < 0 Then
                    RemoveSocket($socket,$i)
                    ContinueLoop
                EndIf
              EndIf
            ;;;If $ret[2] <> ">" Then GUICtrlSetData($edit, GUICtrlRead($edit) & $ret[2])
          Next
       EndIf
    
      
   EndIf
  ;;;GUICtrlSetData($edit, GUICtrlRead($edit) & StringReplace(StringTrimLeft($g_msg,1),@LF & ">",@LF))
   $g_msg = ">"
   Sleep(50)
Dim $SOCK[0]
   $SOCK[0] = DLLCall("betaau3xtra.dll","int","TCPAccept", "int", $MainSocket)
   If $SOCK[0] > -1 Then
      ReDim $socket[Ubound($socket) + 1]
      $socket[0] = Ubound($socket)-1
      $socket[$socket[0]] = $SOCK[0]
   EndIf
  ;;;;WinSetTitle($GOOEY,"",$socket[0] & " clients")
WEnd

ToolTip("closing")

Func RemoveSocket(ByRef $sock, $n)
   Local $array[Ubound($sock)-1]
   Local $z
   $array[0] = Ubound($sock)-2
   $z = 1
   For $j = 1 to Ubound($sock)-1
      If $j <> $n Then
         $array[$z] = $sock[$j]
         $z = $z + 1
      EndIf
   Next
   $sock = $array
EndFunc

Func Proc($szMsg)
   $g_msg = $g_msg & $szMsg & @CRLF
EndFunc

Func OnAutoItExit()
   If $socket[0] > 0 Then
      For $i = 1 to $socket[0]
         DLLCall( "betaau3xtra.dll", "int", "TCPCloseSocket", "int", $socket[$i] )
      Next
   EndIf
   DLLCall( "betaau3xtra.dll", "int", "TCPCloseSocket", "int", $MainSocket )
   DLLCall( "betaau3xtra.dll", "int", "TCPShutDown")
EndFunc

its says to me if i dont dim arrays defore they are set it says invalid use of subscript:(


http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

as it is not a script deliver i I move the topic in the support forum (cannot be a bug) :)

Edited by jpm

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