Jump to content
algiuxas

TCPConnect Error 10060(Timeout)

Recommended Posts

algiuxas

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

42783.png

Share this post


Link to post
Share on other sites
jvds

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
algiuxas

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


42783.png

Share this post


Link to post
Share on other sites
jvds

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
algiuxas

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.


42783.png

Share this post


Link to post
Share on other sites
algiuxas

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.


42783.png

Share this post


Link to post
Share on other sites
jvds

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
algiuxas

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

42783.png

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

    • ripdad
      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.
       
    • ripdad
      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
       
    • ripdad
      By ripdad
      WSA_NBTCP.au3  (Windows Sockets API - Non-Blocking Transmission Control Protocol)
      Version: 1.00
      Type: UDF
      This is an accumulation of WSA code from many sources and modified to suit myself.
      These functions have been thoroughly tested using a Local Proxy Server, which
      is about the most strenuous test you can use.
      Includes my rendition of how a TCPRecv Timeout should work. Also includes a
      timewait/timeout using Select for TCP Send, which works great for that function.
      You will need a loop to use _WSA_TCPRecv(). An example will be forthcoming in a second post.
      Functions:
      #CURRENT_USER_FUNCTIONS
      _WSA_Cleanup
      _WSA_FormatMessage
      _WSA_GetLastError
      _WSA_TCPAccept
      _WSA_TCPCloseSocket
      _WSA_TCPConnect
      _WSA_TCPListen
      _WSA_TCPRecv
      _WSA_TCPSend

      #INTERNAL_FUNCTIONS
      __TimeoutManager
      __TimeoutReset

      #EXTRA_FUNCTIONS
      _WSA_GetAddrInfo
      _WSA_GetHostByAddr
      _WSAAsyncGetHostByName
      _WSAAsyncGetHostByName_Callback
      _WSA_GetNameInfo
       
      Requirements:
      - AutoIt Versions: 3.3.8.1 thru 3.3.15.0 (32Bit only).
      - TCPStartup() at beginning of script on startup.
      - TCPShutDown() and _WSA_Cleanup() on exit.
      Download UDF: WSA_NBTCP.au3
       
    • tarretarretarre
      By tarretarretarre
      AutoIt-SocketIo
      Yep yep, this is pretty much an attempt to port the existing project's concept https://socket.io/ to AutoIt's Codebase. So i will not go in to so much detail.
      This is how the communication is done http://i.imgur.com/0mMfsBD.png Each client is isolated to the server http://i.imgur.com/rVO2LFb.png Features
      Easy API VarType Translation (Example: If the server sends an int, the client will receive an int and vice versa) Fully featured examples Data encryption (Using Autoit's UDF Crypt.au3) Limitations / Drawbacks
      It is not possible to Broadcast/Emit objects Only 1D-arrays are allowed to be Broadcasted/Emitted (2D arrays will probably never be supported) Changelog
      Version 1.5.0 (This update DOES NOT break scripts)
      Added AutoIt like docs under Docs\. The docs are generated so its a 1 to 1 reflection of the UDF headers. Print of documentation Added a production ready server example. Added a new method: _Io_DevDebug which will display useful information when debugging. Added a new method: _Io_SetMaxRecvPackageSize which defaults to whatever _Io_setRecvPackageSize is set to. Added a new method: _Io_setOnPrefix which defaults to _On_ Added a new default client & server event called flood. Flood occurs when exceeding the $__g_io_nMaxPacketSize. $__g_io_nMaxPacketSize is set by _Io_SetMaxRecvPackageSize Fixed the 16 parameter limit when sending data with _Io_Emit, _Io_Broadcast, _Io_BroadcastToAll and _Io_BroadcastToRoom. This works on the same premise that AutoIt's Call Does Fixed a TRUNCATION problem when receiving packages which could cause crashes! Fixed a programming error which caused $__g_ionPacketSize to reset to default 4096 if _Io_Connect or _Io_listenwere called after _Io_setRecvPackageSize Fixed _Io_setEventPreScript and _Io_setEventPostScript They didnt work. Lol. Changed how events are fired so the client cannot crash the server by sending the wrong number of parameters (This also allows for optional parameters on callbacks) Changed _Io_On. The second parameter $fCallback can now be set to null. Doing this, the function assumes that the callback is: _On_<eventName>.  
      Changelog History
      Api methods
      Please see the docs provided
      Default events
      Server events
      connection Client events
      banned Server and Client events
      disconnect flood View source on github
       
      Autoit-Socket-IO-1.0.0.zip (OLD!)
      Autoit-Socket-IO-1.1.0.zip (OLD)
      Autoit-Socket-IO-1.3.0.zip (OLD)
      Autoit-Socket-IO-1.4.0.zip (OLD)
      Autoit-Socket-IO-1.5.0.zip (NEWEST 2017-12-20)
    • timmalos
      By timmalos
      Hello all.
      In case this is interesting few of you, I share my AMCP 2.1 protocol UDF in AutoIT. This protocol is used by CasparCG server, which is a Windows and Linux software used to play out professional graphics, audio and video to multiple outputs as a layerbased real-time compositor. It has been in 24/7 broadcast production since 2006. It's free and opensource.
      The UDF I share allows communication between an AutoIt based client and the CasparCG, based on following documentation : http://casparcg.com/wiki/CasparCG_2.1_AMCP_Protocol
      If you want more details on CasparCG :  official WebSite or have a look to this video
      I'm currently building a full Client based on AutoIt, with many features like drag-and-drop layers, but sadly I can't share it right now, might come later. Don't hesitate to ask questions if you have any or need a basic example.
      The only requirement for this UDF is the other Event-driven TCP UDF by Kip
       
       

      AMCP_shared.au3
      TCP.au3
×