sooo, hab jetzt mal ein Example2 () davor gesetzt, jetzt schließt es zumindest auch den Server mit
heißt, ich hab jetzt eine Funktion drinnen die läuft, aber immer noch anders als ich das eigentlich wollte
weil eigentlich soll der klick auf senden ja eigentlich die eingabe aus dem Inputfeld auslesen und dann an
server schicken. und alles was ich zum vorgänger geändert habe war das ich statt der InputBox eine GUI
mit Inputfeld und Button erstellt habe... und ich habe einen case drinne für den button... demnach könnte
es doch eigentlich nur am Button liegen oder denke ich da grade falsch?
Hier nochmal der Code:
Spoiler anzeigen
;==============================================
;==============================================
;CLIENT! Start Me after starting the SERVER!!!!!!!!!!!!!!!
;==============================================
;==============================================
Example2 ()
Func Example2()
; Set Some reusable info
;--------------------------
Local $ConnectedSocket, $szData
; Set $szIPADDRESS to wherever the SERVER is. We will change a PC name into an IP Address
; Local $szServerPC = @ComputerName
; Local $szIPADDRESS = TCPNameToIP($szServerPC)
Local $szIPADDRESS = @IPAddress1
Local $nPORT = 33891
Local $MainSocket, $GOOEY, $edit, $ConnectedSocket, $szIP_Accepted
Local $msg, $recv
$GOOEY = GUICreate("My Server (IP: " & $szIPADDRESS & ")", 500, 400)
$edit = GUICtrlCreateEdit("", 10, 10, 480, 280)
Local $Input = GUICtrlCreateInput("hi", 10, 300, 480, 80)
$Click = GuiCtrlCreateButton ( "Send", 500, 350, 25, 40)
GUISetState()
; Start The TCP Services
;==============================================
TCPStartup()
; Initialize a variable to represent a connection
;==============================================
$ConnectedSocket = -1
;Attempt to connect to SERVER at its IP and PORT 33891
;=======================================================
$ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)
; If there is an error... show it
If @error Then
MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error)
; If there is no error loop an inputbox for data
; to send to the SERVER.
Else
;Loop forever asking for data to send to the SERVER
While 1
$nMsg = GuiGetMsg ()
Switch $nMsg
; If they cancel the InputBox or leave it blank we exit our forever loop
Case @error
ExitLoop
Case $Click
; InputBox for data to transmit
$szData = GUICtrlRead ($Input)
; We should have data in $szData... lets attempt to send it through our connected socket.
TCPSend($ConnectedSocket, $szData)
; If the send failed with @error then the socket has disconnected
;----------------------------------------------------------------
;~ Case @error
;~ ExitLoop
EndSwitch
WEnd
EndIf
EndFunc ;==>Example
Edit Oscar: Spoiler-Tags hinzugefügt. Bitte bei längeren Quelltexten zusätzlich zu dem AutoIt-Tag auch den Spoiler-Tag benutzen!