Jump to content
algiuxas

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
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()

 

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

  • Similar Content

    • By AoRaToS
      I started working on this program in the summer of 2008 then I stopped cause I faced some problems I couldn't overcome back then. Now that I've practiced more and have become a better scripter/programmer I'm releasing the program to the public to get some opinions. I know it's not a new concept but it's the first program I started besides some small stuff I did just for practice! I won't post the source code yet because it's still under construction, although I'm sure I've posted early stages of the code with bugs in the past in some topic...
      What I wanted was a simple, small, serverless program that would work without installation cause I wanted it for where I work, so I ended up with this!
       
      I have attached some images of various versions, also visit the forum thread.
       
      The package includes s!mpL3 LAN Messenger, the License Agreement and the change log.
       
      Current version 2.9.9.0! [13/06/2019]
       
      Check the Change Log below!
       
       
      http://www.autoitscript.com/forum/index.php?showtopic=88782
       
       
       
      Read the license before using this software.
       
    • By Colduction
      Hello AutoIt programmers🙃
      I don't know how can i aware of my Server IP Address changes
      I want to make program and start it in to check every 1 minute my Server and if IP Address changed then Send POST Action to this URL:
      api.telegram.com
       
       
    • By HansHenrik
      ----------
      edit: this is probably in the wrong place, can a moderator move it to wherever it belongs?
      ----------

      is there any way to completely disable TCPTimeout and make TCPRecv() wait indefinitely? maybe setting it to 0 or -1 or something? 
      the docs doesn't seem to mention any way to disable it

      - the underlying C code would set SO_RCVTIMEO to 0 , aka

      DWORD timeout=0;
      setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
    • By ripdad
      I have had several people ask for this, so I decided to work the algorithm for it and this is the result.
      What is it?
      A Gateway Proxy Sends and Receives Data Unmodified.
      https://en.wikipedia.org/wiki/Proxy_server
      What is it used for?
      You can use it as a gateway, relay or router between two known static IP addresses.
      More information is in the header of the script.
      Download: LocalGatewayProxy.au3
      You will need WSA_NBTCP.au3 from here:
      https://www.autoitscript.com/forum/topic/191954-wsa_nbtcp-v100-udf/
      If you have any questions or problems, let me know.
       
    • By ripdad
      This script is based on algorithm code from EnrMa.
      Updated: January 22, 2018
      Made improvements. Changes are in the script header.
      Known Issues: AutoIt x64 does not work properly with this script.
      Download: LocalProxyServer_v1.00.zip
       
×
×
  • Create New...