Jump to content

TCPConnect Error 10060(Timeout)


Recommended Posts

Hello, I have a problem, I downloaded example of TCP Server and Client, but client doesn't work, It shows TCPConnect 10060 error (timeout), I tried to turn on two servers, I think server work, because one server show 10048 error(Address already in use) I don't know why it doesn't work, I edited that script, but it doesn't work still. I tried TCPConnect and TCPAccept from AutoIt3\Examples\Helpfile, but TCPConnect shows error 10060(timeout)... Anybody knows how to fix it? Thanks :)

; SERVER

#include <Array.au3>
TCPStartup()
Dim $Socket_Data[1]
$Socket_Data[0] = 0
$Listen = TCPListen(@IPAddress1, 1018, 500)
If @error Then
    ConsoleWrite('!-->['&@Hour&":"&@MIN&":"&@SEC&']  TCPListen error. ( ' & @error & ' )' & @CRLF)
    Exit
EndIf
While 1
    For $x = $Socket_Data[0] To 1 Step -1
        $Recv = TCPRecv($Socket_Data[$x], 1000000)
        If $Recv Then
            MsgBox(0, 'Client Number ' & $x & ' with connected socket identifier ' & $Socket_Data[$x], "["&@Hour&":"&@MIN&":"&@SEC&"]"&' Recived msg from Client: ' & @CRLF & $Recv, 5)
            TCPSend($Socket_Data[$x], 'bye')
            TCPCloseSocket($Socket_Data[$x])
            _ArrayDelete($Socket_Data, $x)
            $Socket_Data[0] -= 1
        EndIf
    Next
    _Accept()
WEnd
Func _Accept()
    Local $Accept = TCPAccept($Listen)
    If $Accept <> -1 Then
        _ArrayAdd($Socket_Data, $Accept)
        $Socket_Data[0] += 1
    EndIf
EndFunc   ;==>_Accept

exit
; CLIENT

$Connected = False
TCPStartup()                                        ; Start TCP.
$timespentconnecting = TimerInit( )
Do
   $Socket = TCPConnect(@IPAddress1, 1018)          ; Connect to server.
   $nERROR = @error                                 ; TCPConnect @error.
   If not $nERROR Then                              ; If client connected to server.
      $Connected = True
   Else                                             ; If TCPConnect didn't connected to server.
      ConsoleWrite( "["&@Hour&":"&@MIN&":"&@SEC&"] TCPConnect error. {CODE:" & $nERROR & "}"&@CRLF )    ; Show error.
   EndIf
   sleep(100)                                       ; Sleep 0.1 secounds.
Until $Connected = True or TimerDiff( $timespentconnecting ) > 10000    ; If client connected or timer > 10 secounds, stop trying connect to server.
If $Connected = False then exit                     ; If client didn't connected to server, exit.
TCPSend($Socket, 'Hi there. My computer name is' & ", " & @ComputerName & ", and its drive serial is " & DriveGetSerial(@HomeDrive)); Send to server data.
Do                                                  ; Loop until client recives data from server.
    $Recv = TCPRecv($Socket, 1000000)               ; Recive data from server.
Until $Recv                                         ; Stop looping when data recived from server.
MsgBox(0, "["&@Hour&":"&@MIN&":"&@SEC&"] Recived from server:", $Recv); Show recived data from server.
Exit(0)                                             ; Exit.

 

Edited by algiuxas

After switching years ago to Linux, sadly I don't use AutoIt anymore.

Link to comment
Share on other sites

from what you explained, it seems to me you did run one without running the other one, you can try to compile one and run it, then run the second one from scite or run bouth compiled

If you will try to get it work from 2 computers then run the server on one computer and the client on the other computer, but before you run the client, you need to replace the @IPAddress1 with the IP address of the computer where the server is running

in bouth cases you need to let your firewall allow auto-it access your network when it ask for it, if compiled it till ask you to give acces to the compiled exe

Link to comment
Share on other sites

from what you explained, it seems to me you did run one without running the other one, you can try to compile one and run it, then run the second one from scite or run bouth compiled

If you will try to get it work from 2 computers then run the server on one computer and the client on the other computer, but before you run the client, you need to replace the @IPAddress1 with the IP address of the computer where the server is running

in bouth cases you need to let your firewall allow auto-it access your network when it ask for it, if compiled it till ask you to give acces to the compiled exe

My firewall is always off. I compiled them, but still, it doesn't work. I will try later run server on one computer and client on other computer.
Thanks jvds

After switching years ago to Linux, sadly I don't use AutoIt anymore.

Link to comment
Share on other sites

I tried your code and it worked on my computer, are you running it on a computer with user limits or something like that?

I'm administrator, I just found one thing, Internet Explorer isn't working, I always used Mozzila Firefox.

I will try to reinstall Internet Explorer, maybe this will help.

After switching years ago to Linux, sadly I don't use AutoIt anymore.

Link to comment
Share on other sites

I'm administrator, I just found one thing, Internet Explorer isn't working, I always used Mozzila Firefox.

I will try to reinstall Internet Explorer, maybe this will help.

Internet Explorer works now, but AutoIt TCPConnect still won't work, same error, client can't connect to server, 10060 - timeout.

After switching years ago to Linux, sadly I don't use AutoIt anymore.

Link to comment
Share on other sites

I don't think the auto it TCP functions are Internet explorer Dependant, something else must be wrong,  try this lets see what happens xD

TCPStartup()

$SrvMainsocket = TCPListen(@IPAddress1, 4321, 100)
if @error Then
    consolewrite("!TCPLISTEN FAILED"&@lf)
Else
    consolewrite("TCPLISTEN pass"&@lf)
EndIf

$CliSocket = TCPConnect(@IPAddress1,4321)
if @error Then
    consolewrite("!TCPConnect FAILED"&@lf)
Else
    consolewrite("TCPConnect pass"&@lf)
EndIf

$SrvSubsocket= TCPAccept($SrvMainsocket)
if @error Then
    consolewrite("!$SrvSubsocket FAILED"&@lf)
Else
    consolewrite("$SrvSubsocket pass"&@lf)
EndIf

TCPShutdown()

 

Link to comment
Share on other sites

This is what i get:

TCPLISTEN pass        (PING:1/OFFLINE|TCPListen:1724)
!TCPConnect FAILED    (PING:1/OFFLINE|TCPConnect:-1)
$SrvSubsocket pass    (PING:1/OFFLINE|TCPAccept:-1)
RPC_S_INVALID_NETWORK_OPTIONS
1724 (0x6BC)

The network options are invalid.

Edited by algiuxas

After switching years ago to Linux, sadly I don't use AutoIt anymore.

Link to comment
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
 Share

×
×
  • Create New...