Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Help with TCP

$
0
0
Hello all! I am new to AutoIT, but know the basics. I was recently working on this script, which isn't working. It works locally, but never works when I have a friend try it. I have port forwarded, but it still doesn't work. What I am trying to do, is have a friend run the Server, I run the client, and send messages to his computer.
Server:
[ autoit ]         
HotKeySet("{ESC}", "ExitNow") TCPStartup() $Listening = TCPListen(@IPAddress1, 404) $Accept = TCPAccept($Listening) $Recv = TCPRecv($Accept, 1000000) listen() Func listen() Do $Accept = TCPAccept($Listening) Until $Accept <> -1 recieve() EndFunc ;==>listen Func recieve() Do $Recv = TCPRecv($Accept, 1000000) Until $Recv <> "" Do $Recv2 = TCPRecv($Accept, 1000000) Until $Recv2 <> "" MsgBox(48, $Recv2, $Recv) While 1 WEnd EndFunc ;==>recieve Func ExitNow() TCPShutdown() Exit EndFunc ;==>ExitNow

Client
[ autoit ]         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Client", 313, 100) $Input12 = GUICtrlCreateInput("MsgBox Title Here", 32, 20, 121, 21) $Input1 = GUICtrlCreateInput("Message Here", 32, 50, 121, 21) $Button1 = GUICtrlCreateButton("Send Msg", 184, 20, 100, 50) $flag = 0 GUISetState(@SW_SHOW, $Form1) TCPStartup() $Connect = TCPConnect("FriendsIPHere", 403) If $Connect = -1 Then MsgBox(0, "Error", "Could not connect!") EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 sendit($Connect) EndSwitch WEnd Func sendit($Connect) TCPSend($Connect, GUICtrlRead($Input1)) TCPSend($Connect, GUICtrlRead($Input12)) EndFunc ;==>sendit

Viewing all articles
Browse latest Browse all 12506

Trending Articles