Guest User

Untitled

a guest
Jul 18th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.24 KB | None | 0 0
  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <StaticConstants.au3>
  5. #include <WindowsConstants.au3>
  6. #include <INet.au3>
  7. #Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\tim g\desktop\crypt\form2.kxf
  8. $Form1_1 = GUICreate("Chat", 633, 447, 192, 124)
  9. $Edit = GUICtrlCreateEdit("", 8, 8, 617, 297)
  10. GUICtrlSetData(-1, "")
  11. $Input = GUICtrlCreateInput("", 8, 312, 617, 21)
  12. $OK = GUICtrlCreateButton("Senden", 8, 344, 617, 33, $WS_GROUP)
  13. $Input1 = GUICtrlCreateInput("", 8, 408, 225, 21)
  14. $Label1 = GUICtrlCreateLabel("Naricht senden an Ip:Port :", 8, 384, 131, 17)
  15. $Button1 = GUICtrlCreateButton("Chat Server Starten", 240, 408, 145, 25, $WS_GROUP)
  16. $Button2 = GUICtrlCreateButton("Chat Server Stoppen", 448, 408, 177, 25, $WS_GROUP)
  17. $Input2 = GUICtrlCreateInput("", 392, 408, 49, 21)
  18. $Label2 = GUICtrlCreateLabel("Port Für Deinen Chat Server", 352, 384, 137, 17)
  19. GUISetState(@SW_SHOW)
  20. #EndRegion ### END Koda GUI section ###
  21. global $MainSocket
  22. global $ifTCPON = 0
  23. While 1
  24.     $nMsg = GUIGetMsg()
  25.     Switch $nMsg
  26.         Case $GUI_EVENT_CLOSE
  27.             Exit
  28.         Case $Button1
  29.             TCPStartup()
  30.             global $ip = _GetIP()
  31.             global $port = GUICtrlRead($Input2)
  32.             $MainSocket = TCPListen($ip,$port,20)
  33.             $ifTCPON = 1
  34.             GuictrlSetData($Edit,GUICtrlRead($Edit)&"Chat Server Gestarten auf."&$ip&":"&$port&@CRLF)
  35.         Case $Button2
  36.             TCPShutdown()
  37.             $MainSocket = ""
  38.             $ifTCPON = 0
  39.             GuictrlSetData($Edit,GUICtrlRead($Edit)&"Chat Server Shutdown."&@CRLF)
  40.         Case $OK
  41.             if $ifTCPON = 1 Then
  42.             $var = StringSplit(GuictrlRead($input1),":")
  43.             $SMainSocket = TCPConnect($var[1],$var[2])
  44.             TCPSend($SMainSocket,$ip&":"&$port&" : "&GUICtrlRead($Input))
  45.             GuictrlSetData($Edit,GUICtrlRead($Edit)&"Gesendet an " &GuictrlRead($input1)&" : " &GuictrlRead($input)&@CRLF)
  46.         Else
  47.             GuictrlSetData($Edit,GUICtrlRead($Edit)&"Error: du musst Zuerst ein Chat Server Starten"&@CRLF)
  48.         endif
  49.  
  50.     EndSwitch
  51.     if $ifTCPON = 1 Then
  52.         $NewSocket = TCPAccept($MainSocket)
  53.     If $NewSocket >= 0 Then
  54.         Do
  55.             $Recv = TCPRecv($NewSocket,4096)
  56.         Until $Recv <> ""
  57.        
  58.         GuictrlSetData($Edit,GUICtrlRead($Edit)&"Empfangen von " & $Recv&@CRLF)
  59.     EndIf
  60.     Endif
  61. WEnd
Advertisement
Add Comment
Please, Sign In to add comment