Hallo,
nochmaliger Post:
Ich will ein Chat Programm das alle PC's / Server im LAN erkennt, und an alle (nacheinander) die gleiche Mitteilung sendet.
Hab dazu auch schon Hilfe aus dem Forum bekommen, bin aber leider trotzdem nicht weiter.
![]()
Stand aktuell:
ping an alle PC's funktioniert
kann jedoch keine Nachricht senden ->> _senden func wird nicht gestartet
Könnt ihr mir bitte nochmal weiter helfen und einen Blick auf das client - script werfen !
![]()
server
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
;Opt("TrayMenuMode", 1)
Global $sNamen
Dim $ConnectedSocket[999999]
Dim $Namen[999999]
$Fenster = False
$zahl = -1
$zahl1 = $zahl + 1
$File = @ScriptDir & "\Server.ini"
FileDelete($File)
HotKeySet("{ESC}", "Terminate")
HotKeySet("!{n}", "_Fenster") ; alt + n
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Serververlauf", 500, 201, 303, 219) ;GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )
$Edit1 = GUICtrlCreateEdit("", 3, 3, 498, 196, $ES_READONLY + $ES_AUTOHSCROLL) ;GUICtrlCreateEdit ( "text", left, top [, width [, height [, style [, exStyle]]]] )
GUICtrlSetBkColor(-1, 0xFFFFFF)
#EndRegion ### END Koda GUI section ###
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; Startet den TCP Service
;==============================================
TCPStartup()
; Erstellt einen lauschenden "SOCKET"
;==============================================
$MainSocket = TCPListen(@IPAddress1, 31758)
If $MainSocket > -1 Then
MsgBox(0, "", "Die Server-Ip ist: " & @IPAddress1)
ClipPut(@IPAddress1)
EndIf
If $MainSocket = -1 Then
$MainSocket = TCPListen(@IPAddress2, 31758)
If $MainSocket > -1 Then
MsgBox(0, "", "Die Server-Ip ist: " & @IPAddress2)
EndIf
EndIf
If $MainSocket = -1 Then
$MainSocket = TCPListen(@IPAddress3, 31758)
If $MainSocket > -1 Then
MsgBox(0, "", "Die Server-Ip ist: " & @IPAddress3)
EndIf
EndIf
If $MainSocket = -1 Then
$MainSocket = TCPListen(@IPAddress4, 31758)
If $MainSocket > -1 Then
MsgBox(0, "", "Die Server-Ip ist: " & @IPAddress4)
EndIf
EndIf
If $MainSocket = -1 Then Exit MsgBox(16, "Error", "Es ist ein Verbindungsfehler aufgetreten!")
; Warten auf eine Client-Verbindung
;--------------------
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUISetState(@SW_HIDE)
EndSwitch
$ConnectedSocket[$zahl1] = TCPAccept($MainSocket)
If $ConnectedSocket[$zahl1] >= 0 Then
$zahl = $zahl + 1
$zahl1 = $zahl + 1
;~ MsgBox(0, "", "Mein Server - Client verbunden", 1)
$Erhalten = TCPRecv($ConnectedSocket[$zahl], 2048)
$sErhalten = StringSplit($Erhalten, ",")
If $sErhalten[1] = "Name" Then
$Namen[$zahl] = $sErhalten[2]
ElseIf $sErhalten[1] = "NamenSenden" Then
$zahl = $zahl - 1
For $E = 0 To $sErhalten[2]
$E1 = $E + 3
$Namen[$E] = $sErhalten[$E1]
Next
$Status = False
For $F = 0 To $sErhalten[2]
$F1 = $sErhalten[2] + 1
$F2 = $F - 1
If $F = $sErhalten[$F1] Then $Status = True
If $Status = True Then
$ConnectedSocket[$F] = $ConnectedSocket[$F2]
EndIf
Next
EndIf
$sNamen = ""
For $B = 0 To $zahl
$sNamen = $sNamen & $Namen[$B] & "|"
Next
For $C = 0 To $zahl
TCPSend($ConnectedSocket[$C], "Namen|" & $zahl & "|" & $sNamen)
Next
EndIf
For $A = 0 To $zahl
$Erhalten = TCPRecv($ConnectedSocket[$A], 9999)
$sErhalten = StringSplit($Erhalten, ",")
If $Erhalten <> "" Then
$Edit1Read = GUICtrlRead($Edit1)
GUICtrlSetData($Edit1, $Edit1Read & @CRLF & $Erhalten)
$Lines = _GUICtrlEdit_GetLineCount($Edit1)
_GUICtrlEdit_LineScroll($Edit1, 0, $Lines)
For $D = 0 To $zahl
If $sErhalten[1] = "Name" Then
$Namen[$zahl] = $sErhalten[2]
ElseIf $sErhalten[1] = "Nachricht" Then
MsgBox(0, "", $Namen[$D] & "," & $sErhalten[3])
If $Namen[$D] = $sErhalten[3] Then
TCPSend($ConnectedSocket[$D], $Erhalten)
EndIf
EndIf
Next
; wenn meldung gesendet, fenster anzeigen
GUISetState(@SW_SHOW)
EndIf
Next
WEnd
Func Terminate()
Exit 0
EndFunc ;==>Terminate
Func _Fenster()
If $Fenster = True Then
GUISetState(@SW_HIDE)
ElseIf $Fenster = False Then
GUISetState(@SW_SHOW)
EndIf
EndFunc ;==>_Fenster
client
#include <GUIConstants.au3>
#include <array.au3>
#include <_PingAll.au3>
#include <INet.au3>
#include <ArrayMore.au3>
;$IP = @IPAddress1
;MsgBox ("","","Die Server-Ip ist: " & $IP )
ClipPut(@IPAddress1)
$aPingAll = _PingAll(20, 50, "", "", "", "", "", 0, 0, 0, 0, 0, 5, " ", "1", "0", 0, 0)
;_PingAll($ipstart, $ipend, $iprange = "", $port01 = "", $port02 = "", $port03 = "", $port04 = "",
;$radim = 0, $winxp = 1, $vnc = 1, $ShowName = 1, $ShowMac = 1, $dealy = 100, $slash = "|", $yes = 1, $no = 0, $showprog = 1, $showbevore = 1)
_Array2DEmptyDel($aPingAll, 0) ;_Array2DEmptyDel(ByRef $avArray [, $Col=0])
_ArrayDelete($aPingAll, 0); Erstes Element aus dem Array löschen
$sUbound = (UBound($aPingAll) - 1)
If $aPingAll[$sUbound] = "" Then _ArrayDelete($aPingAll, ($sUbound))
_ArrayDisplay($aPingAll, "ipadress gesamt")
For $x = 0 To UBound($aPingAll) - 1 ;
$IP = $aPingAll[$x]
MsgBox("", "$IP", $IP)
Next
For $z = 0 To UBound($IP) - 1
$Port = 31758
$ConnectedSocket = TCPConnect($IP, $Port)
If $ConnectedSocket = -1 Then
MsgBox(16, "Error", "Es ist bei dem Verbindungsversuch ein Fehler aufgetreten, vermutlich ist kein Server gestartet!")
Exit
Else
MsgBox("", "Erfolg", "$ConnectedSocket: " & $ConnectedSocket)
EndIf
Call("_Senden")
;HotKeySet("^s", "_Senden") ; ctrg + s
While 1
$Empfang = TCPRecv($ConnectedSocket, 9999)
If $Empfang <> "" Then
MsgBox(0, "Nachricht", $Empfang)
EndIf
Sleep(500)
WEnd
Next
Func _Senden()
$Nachricht = InputBox("Nachricht senden Client", "Schreibe deine Nachricht")
If $Nachricht <> "" Then
TCPSend($ConnectedSocket, $Nachricht)
EndIf
EndFunc ;==>_Senden
_PingAll.au3
#include <GUIConstants.au3>
#include <array.au3>
#include <_PingAll.au3>
#include <INet.au3>
#include <ArrayMore.au3>
;$IP = @IPAddress1
;MsgBox ("","","Die Server-Ip ist: " & $IP )
ClipPut(@IPAddress1)
$aPingAll = _PingAll(20, 50, "", "", "", "", "", 0, 0, 0, 0, 0, 5, " ", "1", "0", 0, 0)
;_PingAll($ipstart, $ipend, $iprange = "", $port01 = "", $port02 = "", $port03 = "", $port04 = "",
;$radim = 0, $winxp = 1, $vnc = 1, $ShowName = 1, $ShowMac = 1, $dealy = 100, $slash = "|", $yes = 1, $no = 0, $showprog = 1, $showbevore = 1)
_Array2DEmptyDel($aPingAll, 0) ;_Array2DEmptyDel(ByRef $avArray [, $Col=0])
_ArrayDelete($aPingAll, 0); Erstes Element aus dem Array löschen
$sUbound = (UBound($aPingAll) - 1)
If $aPingAll[$sUbound] = "" Then _ArrayDelete($aPingAll, ($sUbound))
_ArrayDisplay($aPingAll, "ipadress gesamt")
For $x = 0 To UBound($aPingAll) - 1 ;
$IP = $aPingAll[$x]
MsgBox("", "$IP", $IP)
Next
For $z = 0 To UBound($IP) - 1
$Port = 31758
$ConnectedSocket = TCPConnect($IP, $Port)
If $ConnectedSocket = -1 Then
MsgBox(16, "Error", "Es ist bei dem Verbindungsversuch ein Fehler aufgetreten, vermutlich ist kein Server gestartet!")
Exit
Else
MsgBox("", "Erfolg", "$ConnectedSocket: " & $ConnectedSocket)
EndIf
Call("_Senden")
;HotKeySet("^s", "_Senden") ; ctrg + s
While 1
$Empfang = TCPRecv($ConnectedSocket, 9999)
If $Empfang <> "" Then
MsgBox(0, "Nachricht", $Empfang)
EndIf
Sleep(500)
WEnd
Next
Func _Senden()
$Nachricht = InputBox("Nachricht senden Client", "Schreibe deine Nachricht")
If $Nachricht <> "" Then
TCPSend($ConnectedSocket, $Nachricht)
EndIf
EndFunc ;==>_Senden
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]