Sign in to follow this  
Followers 0
lifesux

Client-Server Where is the error ?

19 posts in this topic

Hi guys again :oops: 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.. :bye:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi again :oops:

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 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

Share this post


Link to post
Share on other sites

mm...

Thanks for the answer.

So, how can i fix it as i want ???

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

No :oops: 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
EndIf

Server:

#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 _CommandToAction

My port options are :

Posted Image

and :

Posted Image

Edited by lifesux

Share this post


Link to post
Share on other sites

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 Gude
How 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

Share this post


Link to post
Share on other sites

They are connected same modem. so yes same lan network. Is it problem ???

Share this post


Link to post
Share on other sites

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 Gude
How 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

Share this post


Link to post
Share on other sites

I tryed it at my friend. Still doesnt work. He opened the server but not working :oops:

Share this post


Link to post
Share on other sites

No problem at input. GUI ısnt come. My error message comes :oops:

MsgBox(4112, "error", "error" & @error)

Share this post


Link to post
Share on other sites

I tryed it at my friend. Still doesnt work. He opened the server but not working :oops:

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 Gude
How 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

Share this post


Link to post
Share on other sites

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 ???

Share this post


Link to post
Share on other sites

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 Gude
How 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

Share this post


Link to post
Share on other sites

#15 ·  Posted (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 by lifesux

Share this post


Link to post
Share on other sites

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 Gude
How 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

Share this post


Link to post
Share on other sites

If you have a router - set up port forwarding

Share this post


Link to post
Share on other sites

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. :oops:

I wrote xx .

its : 95.10.40.216

Share this post


Link to post
Share on other sites

#19 ·  Posted (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:

TCPConnect

Success: Returns main socket identifier.

Failure: Returns -1 or 0 and set @error.

@error:

Edited 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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0