home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / socketx / COMEVNT5.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-10-23  |  8.0 KB  |  247 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "Socket/X COM Object --  Connection Test"
  6.    ClientHeight    =   2400
  7.    ClientLeft      =   1935
  8.    ClientTop       =   2745
  9.    ClientWidth     =   5130
  10.    BeginProperty Font 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    LinkTopic       =   "Form1"
  21.    PaletteMode     =   1  'UseZOrder
  22.    ScaleHeight     =   2400
  23.    ScaleWidth      =   5130
  24.    Begin VB.TextBox Text3 
  25.       Appearance      =   0  'Flat
  26.       BeginProperty Font 
  27.          Name            =   "MS Sans Serif"
  28.          Size            =   8.25
  29.          Charset         =   0
  30.          Weight          =   400
  31.          Underline       =   0   'False
  32.          Italic          =   0   'False
  33.          Strikethrough   =   0   'False
  34.       EndProperty
  35.       Height          =   285
  36.       Left            =   1800
  37.       TabIndex        =   2
  38.       Text            =   "5"
  39.       Top             =   1320
  40.       Width           =   855
  41.    End
  42.    Begin VB.TextBox Text2 
  43.       Appearance      =   0  'Flat
  44.       BeginProperty Font 
  45.          Name            =   "MS Sans Serif"
  46.          Size            =   8.25
  47.          Charset         =   0
  48.          Weight          =   400
  49.          Underline       =   0   'False
  50.          Italic          =   0   'False
  51.          Strikethrough   =   0   'False
  52.       EndProperty
  53.       Height          =   285
  54.       Left            =   1800
  55.       TabIndex        =   4
  56.       Text            =   "80"
  57.       Top             =   960
  58.       Width           =   855
  59.    End
  60.    Begin VB.TextBox Text1 
  61.       Appearance      =   0  'Flat
  62.       BeginProperty Font 
  63.          Name            =   "MS Sans Serif"
  64.          Size            =   8.25
  65.          Charset         =   0
  66.          Weight          =   400
  67.          Underline       =   0   'False
  68.          Italic          =   0   'False
  69.          Strikethrough   =   0   'False
  70.       EndProperty
  71.       Height          =   285
  72.       Left            =   1800
  73.       TabIndex        =   3
  74.       Text            =   "198.211.8.88"
  75.       Top             =   600
  76.       Width           =   3015
  77.    End
  78.    Begin VB.CommandButton Command1 
  79.       Appearance      =   0  'Flat
  80.       BackColor       =   &H80000005&
  81.       Caption         =   "Test Connection"
  82.       Default         =   -1  'True
  83.       BeginProperty Font 
  84.          Name            =   "MS Sans Serif"
  85.          Size            =   8.25
  86.          Charset         =   0
  87.          Weight          =   400
  88.          Underline       =   0   'False
  89.          Italic          =   0   'False
  90.          Strikethrough   =   0   'False
  91.       EndProperty
  92.       Height          =   375
  93.       Left            =   1800
  94.       TabIndex        =   0
  95.       Top             =   1920
  96.       Width           =   1695
  97.    End
  98.    Begin VB.Label Label5 
  99.       Alignment       =   1  'Right Justify
  100.       Appearance      =   0  'Flat
  101.       BackColor       =   &H00C0C0C0&
  102.       Caption         =   "(in secs)"
  103.       BeginProperty Font 
  104.          Name            =   "MS Sans Serif"
  105.          Size            =   8.25
  106.          Charset         =   0
  107.          Weight          =   400
  108.          Underline       =   0   'False
  109.          Italic          =   0   'False
  110.          Strikethrough   =   0   'False
  111.       EndProperty
  112.       ForeColor       =   &H80000008&
  113.       Height          =   255
  114.       Left            =   840
  115.       TabIndex        =   8
  116.       Top             =   1560
  117.       Width           =   855
  118.    End
  119.    Begin VB.Label Label4 
  120.       Alignment       =   1  'Right Justify
  121.       Appearance      =   0  'Flat
  122.       BackColor       =   &H00C0C0C0&
  123.       Caption         =   "Interval:"
  124.       BeginProperty Font 
  125.          Name            =   "MS Sans Serif"
  126.          Size            =   8.25
  127.          Charset         =   0
  128.          Weight          =   400
  129.          Underline       =   0   'False
  130.          Italic          =   0   'False
  131.          Strikethrough   =   0   'False
  132.       EndProperty
  133.       ForeColor       =   &H80000008&
  134.       Height          =   255
  135.       Left            =   480
  136.       TabIndex        =   5
  137.       Top             =   1320
  138.       Width           =   1215
  139.    End
  140.    Begin VB.Label Label3 
  141.       Alignment       =   1  'Right Justify
  142.       Appearance      =   0  'Flat
  143.       BackColor       =   &H00C0C0C0&
  144.       Caption         =   "Remote Port:"
  145.       BeginProperty Font 
  146.          Name            =   "MS Sans Serif"
  147.          Size            =   8.25
  148.          Charset         =   0
  149.          Weight          =   400
  150.          Underline       =   0   'False
  151.          Italic          =   0   'False
  152.          Strikethrough   =   0   'False
  153.       EndProperty
  154.       ForeColor       =   &H80000008&
  155.       Height          =   255
  156.       Left            =   360
  157.       TabIndex        =   7
  158.       Top             =   960
  159.       Width           =   1335
  160.    End
  161.    Begin VB.Label Label2 
  162.       Alignment       =   1  'Right Justify
  163.       Appearance      =   0  'Flat
  164.       BackColor       =   &H00C0C0C0&
  165.       Caption         =   "Remote IP:"
  166.       BeginProperty Font 
  167.          Name            =   "MS Sans Serif"
  168.          Size            =   8.25
  169.          Charset         =   0
  170.          Weight          =   400
  171.          Underline       =   0   'False
  172.          Italic          =   0   'False
  173.          Strikethrough   =   0   'False
  174.       EndProperty
  175.       ForeColor       =   &H80000008&
  176.       Height          =   255
  177.       Left            =   600
  178.       TabIndex        =   6
  179.       Top             =   600
  180.       Width           =   1095
  181.    End
  182.    Begin VB.Label Label1 
  183.       Appearance      =   0  'Flat
  184.       BackColor       =   &H00C0C0C0&
  185.       Caption         =   "Result:"
  186.       BeginProperty Font 
  187.          Name            =   "MS Sans Serif"
  188.          Size            =   8.25
  189.          Charset         =   0
  190.          Weight          =   400
  191.          Underline       =   0   'False
  192.          Italic          =   0   'False
  193.          Strikethrough   =   0   'False
  194.       EndProperty
  195.       ForeColor       =   &H80000008&
  196.       Height          =   255
  197.       Left            =   1080
  198.       TabIndex        =   1
  199.       Top             =   120
  200.       Width           =   3975
  201.    End
  202. Attribute VB_Name = "Form1"
  203. Attribute VB_GlobalNameSpace = False
  204. Attribute VB_Creatable = False
  205. Attribute VB_PredeclaredId = True
  206. Attribute VB_Exposed = False
  207. Dim WithEvents SocketXObj1 As SocketXObj
  208. Attribute SocketXObj1.VB_VarHelpID = -1
  209. 'Implements ISocketXObjNotify
  210. Private Sub Command1_Click()
  211.     MousePointer = 11
  212.     Command1.Enabled = False
  213.     Label1.Caption = "Result: "
  214.     'create the socket
  215.     SocketXObj1.LocalAddress = "0.0.0.0"
  216.     SocketXObj1.LocalPort = 0
  217.     SocketXObj1.Create
  218.     'configure the control with the socket
  219.     'of the remote server
  220.     SocketXObj1.RemoteAddress = Text1.Text
  221.     SocketXObj1.RemotePort = CInt(Text2.Text)
  222.     SocketXObj1.Blocking = False
  223.     '
  224.     'attempt to connect
  225.     SocketXObj1.ConnectTimeout = CInt(Text3.Text)
  226.     SocketXObj1.Connect
  227. End Sub
  228. Private Sub Form_Load()
  229.     Set SocketXObj1 = New SocketXObj
  230.     'SocketXCtl1.NotificationObject = Me
  231. End Sub
  232. Private Sub Form_Unload(Cancel As Integer)
  233.     Set SocketXObj1 = Nothing
  234. End Sub
  235. Private Sub SocketXObj1_Done(ByVal LastMethod As SocketXObjLib.MethodsEnum, ByVal ErrorCode As Integer)
  236.     If LastMethod = soxConnect Then
  237.         If ErrorCode = 0 Then
  238.             Label1.Caption = Label1.Caption & "Connection is up."
  239.         Else
  240.             Label1.Caption = Label1.Caption & "Connection is NOT up (" & CStr(ErrorCode) & ")."
  241.         End If
  242.         SocketXObj1.Close
  243.         Command1.Enabled = True
  244.         MousePointer = 0
  245.     End If
  246. End Sub
  247.