tsolrm Posted December 9, 2011 Share Posted December 9, 2011 (edited) Hi guys I want to make a server that's running constantly and receiving messages from different clients. So far i've managed to do it with a simple message from a local client. How can i make it receive messages from any IP, not just local ones? ==server== TCPStartup() $TCPListen = TCPListen (@IPAddress1, 403) Do $TCPAccept = TCPAccept($TCPListen) Until $TCPAccept <> -1 Do $TCPRec = TCPRecv ($TCPAccept, 1000000) Until $TCPRec <> -1 MsgBox (0, "test", $TCPRec) ==client== TCPStartup () $TCPConnect = TCPConnect (@IPAddress1, 403) If $TCPConnect = -1 then MsgBox (0, "no", "no connection") Exit EndIf TCPSend($TCPConnect, "HELLO") Edited December 9, 2011 by tsolrm Link to comment Share on other sites More sharing options...
water Posted December 9, 2011 Share Posted December 9, 2011 I don't see you script limit the IP-addresses it accepts pakets from. Might be your firewall doesn't allow incoming connections. 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...
Akarillon Posted December 9, 2011 Share Posted December 9, 2011 If you move the client to another computer, do you change the ip-adress in the klient script?$TCPConnect = TCPConnect (@IPAddress1, 403)It needs to be changed to the ip-adress of the computer where the server is running.If you do, then check firewall as water said. Challenge accepted! Link to comment Share on other sites More sharing options...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 I have checked the firewall and made sure the port 403 is open. However when i'm trying to run it (at least on the same PC) its not working. Link to comment Share on other sites More sharing options...
water Posted December 9, 2011 Share Posted December 9, 2011 What's missing in your scripts is error checking! Every AutoIt function returns a value or sets @error to show that an error occurred. So please check @error after each TCP function call and post what you get. 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...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 (edited) It's given me an error 10061I've googled it WSAECONNREFUSED 10061 Connection refused. No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running. Edited December 9, 2011 by tsolrm Link to comment Share on other sites More sharing options...
water Posted December 9, 2011 Share Posted December 9, 2011 Do you have any kind of "protection" software installed on the client or server PC? Like virus scanner, HIPS etc. It might not only be the firewall that refuses the connection. Did you check the firewall on both PC's? 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...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 I'm running it on the same PC. Link to comment Share on other sites More sharing options...
water Posted December 9, 2011 Share Posted December 9, 2011 But from your first post I got the impression that the code there was working fine on a single PC. I tested your client/server code and it worked fine. 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...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 no but i tried it like this ==client== $myip = "here's my IP" TCPStartup () $TCPConnect = TCPConnect ($myip, 403) If $TCPConnect = -1 then MsgBox (0, "no", "no connection") Exit EndIf TCPSend($TCPConnect, "HELLO") and it doesn't connect Link to comment Share on other sites More sharing options...
water Posted December 9, 2011 Share Posted December 9, 2011 Could you please restart your PC to make sure that no server/client code is haning around? What do you get if you run the following version with more error checking?$myip = "here's my IP" TCPStartup () msgBox(16, "Info", "TCPStartup: " & @error) $TCPConnect = TCPConnect ($myip, 403) If @error <> 0 then MsgBox (0, "no", "no connection. Error: " & @error) Exit EndIf TCPSend($TCPConnect, "HELLO") MsgBox (16, "Info", "TCPSend: " & @error) 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...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 TCPStartup: 0 and no connection. Error: 10061 Link to comment Share on other sites More sharing options...
water Posted December 9, 2011 Share Posted December 9, 2011 Just to make sure. The server part (as posted at the beginning) is successfully running? 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...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 Yes this code is running ==server== TCPStartup() $TCPListen = TCPListen (@IPAddress1, 403) Do $TCPAccept = TCPAccept($TCPListen) Until $TCPAccept <> -1 Do $TCPRec = TCPRecv ($TCPAccept, 1000000) Until $TCPRec <> -1 MsgBox (0, "test", $TCPRec) expandcollapse popup Link to comment Share on other sites More sharing options... tsolrm Posted December 9, 2011 tsolrm Active Members 145 Author Share Posted December 9, 2011 I don't know, i've tried switching off the firewall completely and the antivirus too! Link to comment Share on other sites More sharing options... water Posted December 9, 2011 water MVPs 26.6k 188 Share Posted December 9, 2011 I modified the scripts a bit so they now write to a log file: Server: #include <file.au3> $iResult = TCPStartup() _FileWriteLog("C:\temp\TCP.log", "TCP Server - TCPStartup return value: " & $iResult & ", @error: " & @error) $TCPListen = TCPListen(@IPAddress1, 403) _FileWriteLog("C:\temp\TCP.log", "TCP Server - TCPListen return value: " & $TCPListen & ", @error: " & @error) Do $TCPAccept = TCPAccept($TCPListen) Until $TCPAccept <> -1 Do $TCPRec = TCPRecv($TCPAccept, 1000000) _FileWriteLog("C:\temp\TCP.log", "TCP Server - TCPRecv return value: " & $TCPRec & ", @error: " & @error) Until $TCPRec <> -1 MsgBox(0, "test", $TCPRec) Client: #include <file.au3> $iResult = TCPStartup() _FileWriteLog("C:\temp\TCP.log", "TCP Client - TCPStartup return value: " & $iResult & ", @error: " & @error & @LF) $TCPConnect = TCPConnect(@IPAddress1, 403) _FileWriteLog("C:\temp\TCP.log", "TCP Client - TCPConnect return value: " & $TCPConnect & ", @error: " & @error) If $TCPConnect = -1 Then MsgBox(0, "no", "no connection") Exit EndIf $iResult = TCPSend($TCPConnect, "HELLO") _FileWriteLog("C:\temp\TCP.log", "TCP Client - TCPSend return value: " & $iResult & ", @error: " & @error) Compile the scripts, start server.exe and then client.exe and post the log file c:\temp\tcp.log 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...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 2011-12-09 17:09:31 : TCP Server - TCPStartup return value: True, @error: 0 2011-12-09 17:09:31 : TCP Server - TCPListen return value: 608, @error: 0 2011-12-09 17:09:34 : TCP Client - TCPStartup return value: True, @error: 0 2011-12-09 17:09:34 : TCP Client - TCPConnect return value: 608, @error: 0 2011-12-09 17:09:34 : TCP Client - TCPSend return value: 5, @error: 0 Link to comment Share on other sites More sharing options...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 Anyone? I thought this is simple enough! Server is on my PC And the client is someplace else and is sending me a simple message using my IP address. But for some reason there is no connection Link to comment Share on other sites More sharing options...
tsolrm Posted December 9, 2011 Author Share Posted December 9, 2011 $TCPConnect = TCPConnect ("my ip", 1111) sleep (5000) After I've put sleep there, it returns $TCPConnect as -1 but @error as 0! What does that mean? Link to comment Share on other sites More sharing options...
water Posted December 10, 2011 Share Posted December 10, 2011 2011-12-09 17:09:31 : TCP Server - TCPStartup return value: True, @error: 0 2011-12-09 17:09:31 : TCP Server - TCPListen return value: 608, @error: 0 2011-12-09 17:09:34 : TCP Client - TCPStartup return value: True, @error: 0 2011-12-09 17:09:34 : TCP Client - TCPConnect return value: 608, @error: 0 2011-12-09 17:09:34 : TCP Client - TCPSend return value: 5, @error: 0 The logfile shows that everything worked fine on the client side. Returnvalue 5 for TCPSend means: 5 bytes sent. On the server side there seems to be a problem with TCPAccept (because the TCPRecv message never shows up). Could you please change the server code and repeat the test: #include <file.au3> $iResult = TCPStartup() _FileWriteLog("C:\temp\TCP.log", "TCP Server - TCPStartup return value: " & $iResult & ", @error: " & @error) $TCPListen = TCPListen(@IPAddress1, 403) _FileWriteLog("C:\temp\TCP.log", "TCP Server - TCPListen return value: " & $TCPListen & ", @error: " & @error) Do $TCPAccept = TCPAccept($TCPListen) _FileWriteLog("C:\temp\TCP.log", "TCP Server - TCPAccept return value: " & $TCPAccept & ", @error: " & @error) Until $TCPAccept <> -1 Do $TCPRec = TCPRecv($TCPAccept, 1000000) _FileWriteLog("C:\temp\TCP.log", "TCP Server - TCPRecv return value: " & $TCPRec & ", @error: " & @error) Until $TCPRec <> -1 MsgBox(0, "test", $TCPRec) 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...
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