lifesux Posted March 27, 2012 Share Posted March 27, 2012 Hi guys again I wrote a script to learn how tou use tcp... It works good on my computer. But it doesnt work other computers. Port 33891 is open. Tested. Client: #include <GUIConstants.au3> $ServerIP = @IPAddress1 $Port = 33891 TCPStartup() $ConnectedSocket = TCPConnect($ServerIP, $Port) If @error Then MsgBox(4112, "error", "error" & @error) Else While 1 $Data = InputBox("command", "write command") If @error or $Data = "" Then ExitLoop TCPSend($ConnectedSocket, $Data) If @error Then ExitLoop WEnd EndIf Server: #include <GUIConstants.au3> $ServerIP = @IPAddress1 $Port = 33891 TCPStartup() $MainSocket = TCPListen($ServerIP, $Port) if $MainSocket = -1 Then Exit $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 While 1 $recv = TCPRecv($ConnectedSocket, 2048) if @error Then ExitLoop if $recv <> "" Then _CommandToAction($recv) EndIf WEnd if $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() Func _CommandToAction($command) $ar = StringSplit($command, "|") Switch $ar[1] Case "Msg" MsgBox(0, $ar[2], $ar[3]) EndSwitch EndFunc Thanks for your helps.. Link to comment Share on other sites More sharing options...
qsek Posted March 27, 2012 Share Posted March 27, 2012 (edited) Hi again I hope you know that @IPAddress1 returns the address of the first network adapter of the local PC where the script is running. Tested the script with my root server IP (server) and my PC (client), and its runnig fine. Edited March 27, 2012 by qsek Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
lifesux Posted March 27, 2012 Author Share Posted March 27, 2012 mm... Thanks for the answer. So, how can i fix it as i want ??? Link to comment Share on other sites More sharing options...
qsek Posted March 28, 2012 Share Posted March 28, 2012 use the internet IP of your server in the client script. Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
lifesux Posted March 28, 2012 Author Share Posted March 28, 2012 (edited) No Still same error. Cant connect. ( i am trying it my other computer. )My codes :Client:#include <GUIConstants.au3> $ServerIP = "192.168.2.4" $Port = 33891 TCPStartup() $ConnectedSocket = TCPConnect($ServerIP, $Port) If @error Then MsgBox(4112, "error", "error" & @error) Else While 1 $Data = InputBox("command", "write command") If @error or $Data = "" Then ExitLoop TCPSend($ConnectedSocket, $Data) If @error Then ExitLoop WEnd EndIfServer:#include <GUIConstants.au3> $ServerIP = "192.168.2.4" $Port = 33891 TCPStartup() $MainSocket = TCPListen($ServerIP, $Port) if $MainSocket = -1 Then Exit $ConnectedSocket = -1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket <> -1 While 1 $recv = TCPRecv($ConnectedSocket, 2048) if @error Then ExitLoop if $recv <> "" Then _CommandToAction($recv) EndIf WEnd if $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() Func _CommandToActionMy port options are :and : Edited March 28, 2012 by lifesux Link to comment Share on other sites More sharing options...
BrewManNH Posted March 28, 2012 Share Posted March 28, 2012 Are the 2 computers on the same LAN network? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
lifesux Posted March 28, 2012 Author Share Posted March 28, 2012 They are connected same modem. so yes same lan network. Is it problem ??? Link to comment Share on other sites More sharing options...
BrewManNH Posted March 28, 2012 Share Posted March 28, 2012 It would only be a problem if they weren't and you were trying to access it through the internet. Check to see if there's a firewall issue that's blocking one or both of the computers from communicating with each other. Turn off all firewalls, including the built-in Windows firewall if it's on, and see if there's any difference. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
lifesux Posted March 28, 2012 Author Share Posted March 28, 2012 I tryed it at my friend. Still doesnt work. He opened the server but not working Link to comment Share on other sites More sharing options...
qsek Posted March 28, 2012 Share Posted March 28, 2012 what do you type into the input field? Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite Link to comment Share on other sites More sharing options...
lifesux Posted March 28, 2012 Author Share Posted March 28, 2012 No problem at input. GUI ısnt come. My error message comes MsgBox(4112, "error", "error" & @error) Link to comment Share on other sites More sharing options...
BrewManNH Posted March 28, 2012 Share Posted March 28, 2012 I tryed it at my friend. Still doesnt work. He opened the server but not working Tried to do what at your friends? Connect 2 computers on the same network or connect his to your computer which is at another location? Remember this if you plan on using this between 2 computers over the internet, the 192.168.xx.xx address is not your real IP address, it's your LAN address, you need the external IP address of your network, the one that the world sees you at. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
lifesux Posted March 28, 2012 Author Share Posted March 28, 2012 Tried to do what at your friends? Connect 2 computers on the same network or connect his to your computer which is at another location? Remember this if you plan on using this between 2 computers over the internet, the 192.168.xx.xx address is not your real IP address, it's your LAN address, you need the external IP address of your network, the one that the world sees you at.So i need to write 95.10.58.2xx to ip part ??? Link to comment Share on other sites More sharing options...
BrewManNH Posted March 28, 2012 Share Posted March 28, 2012 If that's the external IP address that the client needs, then include it in the client script. I'd also use @IPaddress1 in the server script in case you ever use this script on any computer other than the one you wrote it on. Also, your external IP address is probably going to change if you're on dial-up and not an always on connection. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
lifesux Posted March 28, 2012 Author Share Posted March 28, 2012 (edited) Okay understood. My friend is another location So now can you edit my code as i want please? I am trying this and its not working on my own computer. I dont check my friends... client: #include <GUIConstants.au3> $ServerIP = " 95.10.58.2xx" $Port = 33891 TCPStartup() $ConnectedSocket = TCPConnect($ServerIP, $Port) If @error Then MsgBox(4112, "error", "error" & @error) Else While 1 $Data = InputBox("command", "write command") If @error or $Data = "" Then ExitLoop TCPSend($ConnectedSocket, $Data) If @error Then ExitLoop WEnd EndIf server: same ( 1st message ) Edited March 28, 2012 by lifesux Link to comment Share on other sites More sharing options...
BrewManNH Posted March 28, 2012 Share Posted March 28, 2012 Obviously you can't use .2xx as the last digits of your IP address, you have to use the REAL ip address. IP addresses don't have letters in them. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
tsolrm Posted March 29, 2012 Share Posted March 29, 2012 If you have a router - set up port forwarding Link to comment Share on other sites More sharing options...
lifesux Posted March 29, 2012 Author Share Posted March 29, 2012 Obviously you can't use .2xx as the last digits of your IP address, you have to use the REAL ip address. IP addresses don't have letters in them.no. I wrote xx .its : 95.10.40.216 Link to comment Share on other sites More sharing options...
qsek Posted March 29, 2012 Share Posted March 29, 2012 (edited) $ServerIP = " 95.10.58.2xx" ^ You have a space here. Remove it.That is the reason why there is an @error variable.It is used to check what error has happened.From the helpfile:TCPConnectSuccess: Returns main socket identifier.Failure: Returns -1 or 0 and set @error.@error:1 IPAddr is incorrect.2 port is incorrect.windows API WSAGetError return value (see MSDN <http://msdn.microsoft.com/en-us/library/ms740668.aspx>). Edited March 29, 2012 by qsek Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite 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