Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ButtonConstants.au3>
- #include <EditConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- #include <INet.au3>
- #Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\tim g\desktop\crypt\form2.kxf
- $Form1_1 = GUICreate("Chat", 633, 447, 192, 124)
- $Edit = GUICtrlCreateEdit("", 8, 8, 617, 297)
- GUICtrlSetData(-1, "")
- $Input = GUICtrlCreateInput("", 8, 312, 617, 21)
- $OK = GUICtrlCreateButton("Senden", 8, 344, 617, 33, $WS_GROUP)
- $Input1 = GUICtrlCreateInput("", 8, 408, 225, 21)
- $Label1 = GUICtrlCreateLabel("Naricht senden an Ip:Port :", 8, 384, 131, 17)
- $Button1 = GUICtrlCreateButton("Chat Server Starten", 240, 408, 145, 25, $WS_GROUP)
- $Button2 = GUICtrlCreateButton("Chat Server Stoppen", 448, 408, 177, 25, $WS_GROUP)
- $Input2 = GUICtrlCreateInput("", 392, 408, 49, 21)
- $Label2 = GUICtrlCreateLabel("Port Für Deinen Chat Server", 352, 384, 137, 17)
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- global $MainSocket
- global $ifTCPON = 0
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- Exit
- Case $Button1
- TCPStartup()
- global $ip = _GetIP()
- global $port = GUICtrlRead($Input2)
- $MainSocket = TCPListen($ip,$port,20)
- $ifTCPON = 1
- GuictrlSetData($Edit,GUICtrlRead($Edit)&"Chat Server Gestarten auf."&$ip&":"&$port&@CRLF)
- Case $Button2
- TCPShutdown()
- $MainSocket = ""
- $ifTCPON = 0
- GuictrlSetData($Edit,GUICtrlRead($Edit)&"Chat Server Shutdown."&@CRLF)
- Case $OK
- if $ifTCPON = 1 Then
- $var = StringSplit(GuictrlRead($input1),":")
- $SMainSocket = TCPConnect($var[1],$var[2])
- TCPSend($SMainSocket,$ip&":"&$port&" : "&GUICtrlRead($Input))
- GuictrlSetData($Edit,GUICtrlRead($Edit)&"Gesendet an " &GuictrlRead($input1)&" : " &GuictrlRead($input)&@CRLF)
- Else
- GuictrlSetData($Edit,GUICtrlRead($Edit)&"Error: du musst Zuerst ein Chat Server Starten"&@CRLF)
- endif
- EndSwitch
- if $ifTCPON = 1 Then
- $NewSocket = TCPAccept($MainSocket)
- If $NewSocket >= 0 Then
- Do
- $Recv = TCPRecv($NewSocket,4096)
- Until $Recv <> ""
- GuictrlSetData($Edit,GUICtrlRead($Edit)&"Empfangen von " & $Recv&@CRLF)
- EndIf
- Endif
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment