Jump to content
Sign in to follow this  
TSGames

Using TCPListen() on Windows 7

Recommended Posts

TSGames

Hello all,

I'm using AutoIt to create a small Network application, based on TCP.

I created a server and a client code, the server uses TCPListen("",65432,100) to accept connections.

The Client uses TCPConnect("Ip-Address",65432) to connect to the server.

Well, everything works fine if i try it on Windows XP. It also works if I start the server on a Windows XP Machine and connect from a Windows 7 pc.

But I run into problems when I start the server on the Windows 7 pc and try to connect from XP. When Using the TCPConnect() command it always returns -1.

I've disabled the firewall, run as administrator, but it doesn't seems to work for me. I also tried to disable the ip-v6 protocol on the Windows 7 machine, but still I don't get any connection.

I also tried to compile the script with the latest Autoit Beta (3.3.1.5) - same error.

I hope that someone can give me a hint.

Thanks for any suggestions!

Share this post


Link to post
Share on other sites
Richard Robertson

Are you able to connect to Windows 7 from Windows 7? If not, then you may have another issue.

Share this post


Link to post
Share on other sites
TSGames

Thanks for your fast answer!

No, I also can't get any connection if i try to connect to "127.0.0.1" on the Windows 7 machine. It also returns -1 at TCPConnect()

Regards

TSGames

Share this post


Link to post
Share on other sites
Richard Robertson

That's interesting. Have you tried a different port number to see if that's the problem?

Like just try this pair of scripts.

TCPStartup()
$socket = TCPListen("", 12345, 10)
While True
    $newsocket = TCPAccept($socket)
    If $newsocket != -1 Then
        MsgBox(0, "Connected", "Connected")
        Exit
    EndIf
    Sleep(100)
WEnd

TCPStartup()
$socket = TCPConnect("", 12345)
MsgBox(0, "", "Socket = " & $socket)

Share this post


Link to post
Share on other sites
TSGames

Well, now I found out something interesting.

If i create a Socket to Listen on the Windows 7 machine as in your example

TCPListen("",12345,10)

it returns -1 and sets @error to 1

(On the windows xp machine it returns an id and no error).

So, if I enter an ip which is allowed to connect to, as 127.0.0.1, it returns an id and succeed.

If I now connect using TCPConnect("127.0.0.1",12345) it works fine, but only if I actually connect from this ip.

For example, if I call TCPConnect with the own LAN-IP, it doesn't work

But how can I get it work to connect regardless of the client's ip?

[EDIT] TCPListen(0,12345,10) seems to work. May should be documented in future versions?

Thanks

TSGames

Edited by TSGames

Share this post


Link to post
Share on other sites
Richard Robertson

0 might be better to use than the empty string. Or perhaps "0.0.0.0".

I'm not sure what the problem is exactly, but using 0 seems to work for you so go with that.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.