Jump to content

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 = ""
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
;define Functions
Func Conn_Tester()

    ; Start The TCP Services

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

    ;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

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

        ;close currently opened socket to clean up

    ;run connection dropping handler
    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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...