Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

TCPlisten TCPaccept problem ?


  • Please log in to reply
4 replies to this topic

#1 vlad2048

vlad2048

    Seeker

  • Active Members
  • 6 posts

Posted 22 April 2010 - 06:48 AM

I'm trying to get a simple AutoIt TCP client/server working.
I'm pretty sure of the code, I checked the help and the forums.

It's a bit complicated
- It works on the same machine (client connects to server)
- It doesn't work on 2 different machines (client fails to connect with WSA error 10061)
- I've tried a very basic tcp echo server/client (http://www.mycplus.com/source-code/c-source-code/tcp-client-and-server/) and it works between my 2 machines. So the problem is not my machines.
- The AutoIt client can connect to the previous echo server
- The echo client cannot connect to the AutoIt server (error 10061)

I'm CERTAIN of my tests, so really there's a problem with the AutoIt server
What is wrong with ? Here's the code
$g_IP = "127.0.0.1" TCPStartup() $mainSocket = TCPListen($g_IP, 1040) if ($mainSocket = -1) then     MsgBox(0, "error", "failed to creaste listening socket") EndIf $clientSock = -1 do     $clientSock = TCPAccept($mainSocket) until $clientSock <> -1 msgbox(0, "good", "client connected")








#2 vlad2048

vlad2048

    Seeker

  • Active Members
  • 6 posts

Posted 22 April 2010 - 06:52 AM

Ah it's always just after posting that I find the solution usually :idea:
In the server, I should have written
$mainSocket = TCPListen("", 1044)

instead of
$mainSocket = TCPListen("127.0.0.1", 1044)

Maybe the help file is wrong ?

#3 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,686 posts

Posted 22 April 2010 - 11:42 AM

Maybe the help file is wrong ?

Wrong how, I can't see where it mentions empty quotes?

#4 vlad2048

vlad2048

    Seeker

  • Active Members
  • 6 posts

Posted 22 April 2010 - 08:10 PM

Wrong how, I can't see where it mentions empty quotes?

Well, I need the empty quotes to make it work. Putting in "127.0.0.1" like in the help file doesn't work for me.
I think it's quite strange ? What does TCPListen does with that argument exactly ?

#5 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,686 posts

Posted 22 April 2010 - 11:34 PM

Oh excuse me, I kind of read wrong up there. The IPAddr-parameter is what IP TCPListen shall "work" on, and 127.0.0.1 is localhost, so obviously that wont work if you want another machine to be able to connect :)
I would guess that setting an empty string ("") sets it as 0.0.0.0 which means it listens to everything (please correct me if I'm wrong!).

In short: set the IP to where you want people to be able to connect from. If you want another machine to connect don't set it to localhost.

:idea:

Edit: Added link.

Edited by AdmiralAlkex, 22 April 2010 - 11:35 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users