home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{C7212F93-30E8-11D2-B450-0020AFD69DE6}#1.0#0"; "SocketX.OCX"
- Begin VB.Form Form1
- Caption = "Connect To Remote Server"
- ClientHeight = 5400
- ClientLeft = 1140
- ClientTop = 1515
- ClientWidth = 9480
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 5400
- ScaleWidth = 9480
- Begin SocketXCtl.SocketXCtl SocketX
- Left = 1440
- Top = 4440
- _cx = 847
- _cy = 847
- AcceptTimeout = 0
- BlockingMode = -842150451
- Blocking = -1 'True
- BroadcastEnabled= -1 'True
- ConnectTimeout = 0
- EventMask = 63
- KeepAliveEnabled= 0 'False
- LibraryName = "WSOCK32.DLL"
- LingerEnabled = 0 'False
- LingerMode = 0
- LingerTime = 0
- LocalAddress = ""
- LocalPort = 0
- OutOfBandEnabled= 0 'False
- ReceiveBufferSize= 8192
- ReceiveTimeout = 0
- RemoteAddress = ""
- RemoteName = ""
- ReuseAddressEnabled= 0 'False
- RemotePort = 0
- RouteEnabled = -1 'True
- SendTimeout = 0
- SendBufferSize = 8192
- SocketType = 0
- TcpNoDelayEnabled= 0 'False
- End
- Begin VB.ListBox List2
- Height = 3375
- Left = 5760
- TabIndex = 12
- Top = 1800
- Width = 3495
- End
- Begin VB.CheckBox Check1
- Caption = "Blocking"
- Height = 375
- Left = 120
- TabIndex = 9
- Top = 3840
- Width = 1095
- End
- Begin VB.TextBox Text1
- Height = 285
- Left = 840
- TabIndex = 6
- Text = "Text1"
- Top = 3000
- Width = 375
- End
- Begin VB.CommandButton Command1
- Caption = "Connect"
- Height = 375
- Left = 120
- TabIndex = 1
- Top = 4560
- Width = 1095
- End
- Begin VB.ListBox List1
- Height = 840
- Left = 120
- TabIndex = 0
- Top = 1560
- Width = 2295
- End
- Begin VB.Line Line2
- BorderColor = &H80000010&
- X1 = 0
- X2 = 9480
- Y1 = 1320
- Y2 = 1320
- End
- Begin VB.Line Line1
- BorderColor = &H80000010&
- X1 = 5640
- X2 = 5640
- Y1 = 1320
- Y2 = 5400
- End
- Begin VB.Label Label8
- Caption = "Trace Messages:"
- Height = 255
- Left = 5760
- TabIndex = 11
- Top = 1560
- Width = 1455
- End
- Begin VB.Label Label7
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1095
- Left = 0
- TabIndex = 10
- Top = 120
- Width = 9255
- End
- Begin VB.Label Label6
- Caption = "You can run this sample in either blocking or non-blocking mode."
- Height = 495
- Left = 2640
- TabIndex = 8
- Top = 3840
- Width = 2775
- End
- Begin VB.Label Label5
- Caption = "When an address is displayed try connecting using the Connect button."
- Height = 615
- Left = 2640
- TabIndex = 7
- Top = 4560
- Width = 2775
- End
- Begin VB.Label Label4
- Caption = "Timeout:"
- Height = 255
- Left = 120
- TabIndex = 5
- Top = 3000
- Width = 615
- End
- Begin VB.Label Label3
- Caption = "Host Not Found"
- Height = 255
- Left = 120
- TabIndex = 4
- Top = 2520
- Width = 2055
- End
- Begin VB.Label Label2
- Caption = "You may change the timeout if you choose. Timeouts are specified in seconds."
- Height = 615
- Left = 2640
- TabIndex = 3
- Top = 2880
- Width = 2775
- End
- Begin VB.Label Label1
- Caption = "Choose a server from the list. If the server's address can be found it will be displayed just below the list. "
- Height = 735
- Left = 2640
- TabIndex = 2
- Top = 1560
- Width = 2775
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub Trace(s As String)
- If (List2.ListCount > 100) Then
- List2.RemoveItem 0
- End If
- List2.AddItem s
- List2.TopIndex = List2.NewIndex
- End Sub
- Private Sub Command1_Click()
- SocketX.ConnectTimeout = CInt(Text1.Text)
- SocketX.Blocking = Check1.Value
- On Error Resume Next
- Screen.MousePointer = 11
- SocketX.Connect , 21
- Screen.MousePointer = 0
- End Sub
- Private Sub Form_Load()
- Me.Show
- List1.AddItem "ftp.mabry.com"
- List1.AddItem "enews.newsguy.com"
- List1.AddItem "www.mabry.com"
- List1.AddItem "always.fails.com"
- Text1.Text = SocketX.ConnectTimeout
- SocketX.Blocking = True
- SocketX.BlockingMode = soxPseudoBlocking
- Check1.Value = 1
- SocketX.Create
- DoEvents
- List1.ListIndex = 0
- End Sub
- Private Sub List1_Click()
- '
- ' Enable name/address translation
- '
- Screen.MousePointer = 11
- Command1.Enabled = False
- Trace "Starting address lookup"
- SocketX.RemoteNameAddrXlate = True
- Label3.Caption = "Looking up address"
- DoEvents
- SocketX.RemoteName = List1.List(List1.ListIndex)
- Trace "Address lookup complete"
- If (SocketX.RemoteAddress = "") Then
- Label3.Caption = "Host Not Found"
- Else
- Label3.Caption = SocketX.RemoteAddress
- End If
- Command1.Enabled = True
- Screen.MousePointer = 0
- End Sub
- Private Sub SocketX_Done(ByVal LastMethod As SocketXCtl.MethodsEnum, ByVal ErrorCode As Integer)
- Trace "Done( " & LastMethod & ", " & ErrorCode & ")"
- Select Case (LastMethod)
- Case soxConnect
- Trace "Connect"
- If (SocketX.Blocking = True) Then
- SocketX_Connect ErrorCode
- End If
- Case soxClose
- Trace "Close"
- Case soxCreate
- Trace "Create"
- End Select
- End Sub
- Private Sub SocketX_Connect(ByVal ErrorCode As Integer)
- Trace "Connect(" & ErrorCode & ")"
- '
- ' Connect finished, let's see what happened
- '
- If (ErrorCode) Then
- Trace "Connect failed: " & ErrorCode
- Else
- Trace "Connected!"
- End If
- '
- ' Close socket and recreate for next try.
- '
- SocketX.Close
- SocketX.Create
- End Sub
-