Jump to content

Problems with TCPConnect


Recommended Posts

i have a script that checks connection for a server it opens TCP service with TCPStartUp(), then users TCPConnect to open a connection then if is connected closes it with TCPCloseSocket then opens another connection and so on in a loop until a connection is lost, then calls another function for suspend/resume an external application (in my case an oracle form).

i'm trying to make a script so that it would be running in the background and suspend the oracle form until connection is restored then resume the form so that data won't be lost i know that i'll have to make the form reconnect again but i'm trying to do that currently but until then i need to know if the TCPConnect & TCPCloseSocket will cause any problems if they keep running infinitely , i mean i opened TCPview(the one from sysinternals) and i viewed the network traffic i found a lot of network traffic that are "closed" or "time_wait" and i don't know if that would cause any problems when applying on 10 clients or more.

here's the code i wrote:

; ***************************************************************
; Compuhosp Company (c) 2011 All Rights Reserverd.
; Created By Mohamed Nasr 2011.
; *****************************************************************

;include area
#include <GUIConstantsEx.au3>
#include <Process_suspend.au3>

;********************************************************************
;hide tray icon
AutoItSetOption("TrayIconHide" ,1)

;pre define variables to reduce bugs
Opt('MustDeclareVars', 1)
Opt("WinTextMatchMode", 3)      ;1=complete, 2=quick, 3=exact title

; Set Some global variables
;========================
Global $nPORT = 1521, $server_IP = "192.168.1.210"
Global $MainSocket, $GOOEY, $edit, $ConnectedSocket, $GUIO, $edit1, $ConnectedSocket2
Global $msg, $recv
Global $CID

run("C:\oracle\orant\BIN\ifrun60.exe c:\rest\forms\logon_ar.fmx")

; Run Functions
Conn_Tester()
;define Functions
Func Conn_Tester()

    ; Start The TCP Services
    ;==============================================
    TCPStartUp()

    ;create new GUI to show connected server IP
    ;------------------------------------------
    $GUIO = GUICreate("My Server (IP: " & $server_IP & ")", 300, 200)
    $edit1 = GUICtrlCreateEdit("", 10, 10, 280, 180)
    GUISetState()

    ;Wait for and Accept a connection
    ;==============================================
    While 1

        $msg = GUIGetMsg()

        ; GUI Closed
        ;--------------------
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop



        $ConnectedSocket = TCPConnect( $server_IP, $nPORT )
        If $ConnectedSocket = -1 Then
            TCPCloseSocket($ConnectedSocket)
            ExitLoop
        EndIf

        ;write to GUI
        ;--------------
        GUICtrlSetData($edit1, "Connected toserver : " & $server_IP &  @CRLF & GUICtrlRead($edit1))

        ;close currently opened socket to clean up
        ;=========================================
        TCPCloseSocket($ConnectedSocket)
    WEnd

    ;run connection dropping handler
    ;===============================
    GUIDelete()
    conn_Dropper() ;===>Another Function

EndFunc   ;==>End of conn_tester

Please, if anyone can tell me how this infinite loop of opening and closing TCP connection could affect network traffic, and how this script could be improved

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

  • Recently Browsing   0 members

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