Jump to content

Recommended Posts

Posted (edited)

I'm failing miserably trying to create a TCP client server over internet.

Firewalls disabled on both machines, Client PC can ping Server PC, and visa-versa. also both client and server allowed programs in their respective firewalls anyway.

Error is from TCPConnect() in client.

Server PC has direct connection to Router-less modem (no port forwarding)

Server

TCPStartup()
;Global $IP = _GetIP()
Global $IP = @IPAddress1
;Global $IP = "0.0.0.0"
ConsoleWrite($IP & @LF)
Global $Socket_Data[1]
$Socket_Data[0] = 0
$Listen = TCPListen($IP, 45962, 500)
If @error Then
    ConsoleWrite('!--> TCPListen error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPListen to get more info about this 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], '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
        ConsoleWrite("New Connection" & @LF)
        _ArrayAdd($Socket_Data, $Accept)
        $Socket_Data[0] += 1
    EndIf
EndFunc   ;==>_Accept

Client

#include <Inet.au3>
;ConsoleWrite(_GetIP() & @LF)
TCPStartup()
$Socket = TCPConnect("x.x.x.x", 45962); Remote public IP
If @error Then
    MsgBox(0,0,'!--> TCPConnect error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPConnect to get more info about this error.')
    ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPConnect to get more info about this error.' & @CRLF)
    ConsoleWrite('!--> ' & $Socket & @LF)
    Exit
EndIf
TCPSend($Socket, 'Hi there. My computer name is' & ", " & @ComputerName & ", and its drive serial is " & DriveGetSerial(@HomeDrive))
Do
    $Recv = TCPRecv($Socket, 1000000)
Until $Recv
MsgBox(0, 'Recived from server:', $Recv)

Ran both from script and compiled script with and without admin.

Error...

!--> TCPConnect error number ( 10061 ), look in the help file (on MSDN link) on func TCPConnect to get more info about this error.

WSAECONNREFUSED
10061
Connection refused.
No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.

Any Ideas folks? I've read a lot of posts with this problem but no posted solutions.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...