SkellySoul Posted October 18, 2012 Share Posted October 18, 2012 Hi. I have a problem with this script...@IPAddress1 works fine but using _GetIP() causes an error. expandcollapse popup#include <Inet.au3> #include <Misc.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _Singleton(@ScriptName) Global $IP = _GetIP() , $Port = 80 TCPStartup() $MainSocket = TCPListen($IP, $Port) If $MainSocket = -1 Then MsgBox(0 , "", "Error?") Exit EndIf $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() ExitLoop EndIf $Recv = TCPRecv($ConnectedSocket, 2048) If $Recv = "Test" Then ConsoleWrite("Online") WEnd Link to comment Share on other sites More sharing options...
trancexx Posted October 18, 2012 Share Posted October 18, 2012 You are mixing up several different things. Google port forwarding. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
water Posted October 18, 2012 Share Posted October 18, 2012 What do you mean by "causes an error"? Do you get an error message? Does the script crash? ... My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
SkellySoul Posted October 18, 2012 Author Share Posted October 18, 2012 (edited) I catch an error at this part of the script. If $MainSocket = -1 Then MsgBox(0 , "", "Error?") Exit EndIf Edited October 18, 2012 by SkellySoul Link to comment Share on other sites More sharing options...
Chance Posted October 18, 2012 Share Posted October 18, 2012 (edited) I don't know much about this, but I port fowarded port 8080 to my PC from my router thing, and modified your example a little and seemed to work expandcollapse popup#include <Misc.au3> #include <Inet.au3> HotKeySet("{ESC}", "_Exit") Global $IP = _GetIP() , $Port = 8080 TCPStartup() If _Singleton("MainInstance", 1) = 0 Then Global $Server = TcpConnect($IP, $Port) TCPSend($Server, "Test") TCPCloseSocket($Server) TCPShutdown() Exit EndIf $MainSocket = TCPListen(@IPAddress1, $Port) If $MainSocket = -1 Then MsgBox(0 , "Error!", "Could not listen in on port ;_;") Exit 1 EndIf Switch @Compiled Case 1 Run(FileGetShortName(@ScriptFullPath)) Case 0 Run(FileGetShortName(@AutoItExe) & ' /AutoIt3ExecuteScript ' & FileGetShortName(@ScriptFullPath)) EndSwitch $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 While 1 $Recv = TCPRecv($ConnectedSocket, 2048) If $Recv = "Test" Then ConsoleWrite("Online" & @CR) _Exit() EndIf WEnd Func _Exit() TCPCloseSocket($ConnectedSocket) TCPShutdown() Exit EndFunc Edited October 18, 2012 by FlutterShy Link to comment Share on other sites More sharing options...
SkellySoul Posted October 18, 2012 Author Share Posted October 18, 2012 I guess port forwarding is the issue for me. I am wondering is there any way to avoid port forwarding because I don't really want to have to mess with my router if I don't have to. Link to comment Share on other sites More sharing options...
Chance Posted October 18, 2012 Share Posted October 18, 2012 I guess port forwarding is the issue for me.I am wondering is there any way to avoid port forwarding because I don't really want to have to mess with my router if I don't have to.That's probably not an option Things like that are usually really hard, whereever the server's going to be located, it's going to have to have the port it's going to listen on to forwarded to it unless oyu can find out how things like skype and utorrent do it . Link to comment Share on other sites More sharing options...
Developers Jos Posted October 18, 2012 Developers Share Posted October 18, 2012 Your router does NATting which means you are sharing with multiple computers on the inside a single IP address on the outside. There is no way to initiate a connection from the outside in unless you port-forward or define a single internal IPaddress which will receive all inbound connections (DMZ host). Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SkellySoul Posted October 18, 2012 Author Share Posted October 18, 2012 Thanks very much for the help and information everyone I only plan on having the server run on my computer but it's just I don't really like the idea of having to configure the router/hardware but I guess it is no big deal. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now