home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form client
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "Client Test"
- ClientHeight = 6240
- ClientLeft = 585
- ClientTop = 1620
- ClientWidth = 6960
- Height = 6645
- Icon = 0
- Left = 525
- LinkTopic = "Form1"
- ScaleHeight = 6240
- ScaleWidth = 6960
- Top = 1275
- Width = 7080
- Begin TextBox localport
- Height = 285
- Left = 120
- TabIndex = 22
- Top = 4920
- Width = 2175
- End
- Begin TextBox localaddress
- Height = 285
- Left = 120
- TabIndex = 21
- Top = 4320
- Width = 2175
- End
- Begin FSSocket FSSocket1
- Connect = 0 'False
- EOL = ""
- HostAddress = "127.0.0.1"
- HostName = "localhost"
- InputBufferSize = 8192
- Left = 1785
- Listen = 0 'False
- ListenPort = 0
- OutputBufferSize= 8192
- PortNumber = 0
- Protocol = 0 'TCP
- ServiceName = ""
- Top = 1065
- End
- Begin CommandButton Command4
- Caption = "Set"
- Height = 255
- Left = 1800
- TabIndex = 6
- Top = 2520
- Width = 495
- End
- Begin CommandButton Command3
- Caption = "Set"
- Height = 255
- Left = 1800
- TabIndex = 4
- Top = 1920
- Width = 495
- End
- Begin CommandButton Command2
- Caption = "Disconnect"
- Enabled = 0 'False
- Height = 375
- Left = 1080
- TabIndex = 10
- Top = 5760
- Width = 1215
- End
- Begin TextBox SVSNAM
- Height = 285
- Left = 120
- TabIndex = 8
- Top = 3720
- Width = 2175
- End
- Begin TextBox PORTNUM
- Height = 285
- Left = 120
- TabIndex = 7
- Top = 3120
- Width = 2175
- End
- Begin TextBox HSTADDR
- Height = 285
- Left = 120
- TabIndex = 5
- Top = 2520
- Width = 1575
- End
- Begin OptionButton TCP
- BackColor = &H00C0C0C0&
- Caption = "TCP"
- Height = 255
- Left = 120
- TabIndex = 1
- Top = 960
- Value = -1 'True
- Width = 1095
- End
- Begin OptionButton UDP
- BackColor = &H00C0C0C0&
- Caption = "UDP"
- Height = 255
- Left = 120
- TabIndex = 2
- Top = 1320
- Width = 1095
- End
- Begin TextBox HSTNAM
- Height = 285
- Left = 120
- TabIndex = 3
- Top = 1920
- Width = 1575
- End
- Begin CheckBox RDYTOSND
- BackColor = &H00C0C0C0&
- Caption = "Ready to Send"
- Height = 255
- Left = 120
- TabIndex = 14
- TabStop = 0 'False
- Top = 120
- Width = 1695
- End
- Begin CheckBox CNTD
- BackColor = &H00C0C0C0&
- Caption = "Connected"
- Height = 255
- Left = 120
- TabIndex = 13
- TabStop = 0 'False
- Top = 480
- Width = 1455
- End
- Begin CommandButton Command1
- Caption = "Connect"
- Height = 375
- Left = 1080
- TabIndex = 9
- Top = 5400
- Width = 1215
- End
- Begin TextBox OUTDATA
- Height = 285
- Left = 3105
- TabIndex = 0
- Top = 5880
- Width = 3735
- End
- Begin TextBox INDATA
- Height = 5775
- Left = 2400
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 11
- TabStop = 0 'False
- Top = -15
- Width = 4575
- End
- Begin Label Label7
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Local Port"
- Height = 195
- Left = 120
- TabIndex = 20
- Top = 4680
- Width = 885
- End
- Begin Label Label6
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Local Address"
- Height = 195
- Left = 120
- TabIndex = 19
- Top = 4080
- Width = 1215
- End
- Begin Label Label5
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Service"
- Height = 195
- Left = 120
- TabIndex = 18
- Top = 3480
- Width = 660
- End
- Begin Label Label4
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Port"
- Height = 195
- Left = 120
- TabIndex = 17
- Top = 2880
- Width = 360
- End
- Begin Line Line2
- X1 = 2400
- X2 = 2400
- Y1 = 0
- Y2 = 6240
- End
- Begin Line Line1
- X1 = 0
- X2 = 2400
- Y1 = 840
- Y2 = 840
- End
- Begin Label Label3
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "HostAddress"
- Height = 195
- Left = 120
- TabIndex = 16
- Top = 2280
- Width = 1080
- End
- Begin Label Label2
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "HostName"
- Height = 195
- Left = 120
- TabIndex = 15
- Top = 1680
- Width = 885
- End
- Begin Label Label1
- Alignment = 1 'Right Justify
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Input:"
- Height = 255
- Left = 2520
- TabIndex = 12
- Top = 5880
- Width = 510
- End
- Dim lastchanged As Integer
- Private Sub Command1_Click ()
- fssocket1.EOL = Chr$(10)
- On Error GoTo errx
- fssocket1.Connect = True
- LocalAddress.Text = fssocket1.LocalAddress
- LocalPort.Text = fssocket1.LocalPort
- If fssocket1.Protocol = 1 Then
- command2.Enabled = True
- command1.Enabled = False
- End If
- Exit Sub
- errx:
- MsgBox fssocket1.WSALastErrorMsg
- Resume Next
- End Sub
- Private Sub Command2_Click ()
- fssocket1.Connect = False
- LocalAddress.Text = ""
- LocalPort.Text = ""
- End Sub
- Private Sub Command3_Click ()
- On Error Resume Next
- fssocket1.HostName = HSTNAM.Text
- hstaddr.Text = fssocket1.HostAddress
- End Sub
- Private Sub Command4_Click ()
- On Error Resume Next
- fssocket1.HostAddress = hstaddr.Text
- HSTNAM.Text = fssocket1.HostName
- End Sub
- Private Sub Form_Load ()
- INDATA.Text = ""
- OUTDATA.Text = ""
- HSTNAM.Text = fssocket1.HostName
- hstaddr.Text = fssocket1.HostAddress
- PORTNUM.Text = fssocket1.PortNumber
- SVSNAM.Text = fssocket1.ServiceName
- If fssocket1.Protocol = 0 Then
- TCP.Value = True
- Else
- UDP.Value = True
- End If
- Load Server
- lastchanged = 0
- End Sub
- Private Sub Form_Unload (Cancel As Integer)
- Unload Server
- End Sub
- Private Sub FSSocket1_Connected (StatusCode As Integer, Description As String)
- CNTD.Value = 1
- RDYTOSND.Value = 1
- command1.Enabled = False
- command2.Enabled = True
- LocalAddress.Text = fssocket1.LocalAddress
- LocalPort.Text = fssocket1.LocalPort
- End Sub
- Private Sub FSSocket1_DataReceived (Text As String, EOL As Integer)
- Static fulstrng As String
- fulstrng = fulstrng + Text
- If EOL Then
- INDATA.SelStart = 32000
- INDATA.SelText = fulstrng & Chr$(13) & Chr$(10)
- fulstrng = ""
- End If
- If fssocket1.Protocol = 1 Then
- PORTNUM.Text = fssocket1.PortNumber
- hstaddr.Text = fssocket1.HostAddress
- End If
- End Sub
- Private Sub FSSocket1_Disconnected (StatusCode As Integer, Description As String)
- CNTD.Value = 0
- RDYTOSND.Value = 0
- command1.Enabled = True
- command2.Enabled = False
- LocalAddress.Text = ""
- LocalPort.Text = ""
- End Sub
- Private Sub FSSocket1_ReadyToSend ()
- RDYTOSND.Value = 1
- End Sub
- Private Sub HSTADDR_KeyPress (keyascii As Integer)
- On Error Resume Next
- If keyascii = 13 Then
- fssocket1.HostAddress = hstaddr.Text
- HSTNAM.Text = fssocket1.HostName
- keyascii = 0
- End If
- End Sub
- Private Sub HSTNAM_KeyPress (keyascii As Integer)
- On Error Resume Next
- If keyascii = 13 Then
- fssocket1.HostName = HSTNAM.Text
- hstaddr.Text = fssocket1.HostAddress
- keyascii = 0
- End If
- End Sub
- Private Sub OUTDATA_KeyPress (keyascii As Integer)
- On Error GoTo cantsend
- Dim x As Integer
- If keyascii = 13 Then
- If fssocket1.Connect = True Then
- If fssocket1.Protocol = 1 Then
- fssocket1.HostAddress = hstaddr.Text
- End If
- fssocket1.Send = OUTDATA.Text & Chr$(10)
- End If
- OUTDATA.Text = ""
- keyascii = 0
- End If
- Exit Sub
- cantsend:
- If fssocket1.WSALastError = 10035 Then
- RDYTOSND.Value = 0
- While RDYTOSND.Value = 0
- DoEvents
- Wend
- Else
- MsgBox fssocket1.WSALastErrorMsg
- Exit Sub
- End If
- Resume
- End Sub
- Private Sub PORTNUM_Change ()
- On Error Resume Next
- fssocket1.PortNumber = PORTNUM.Text
- SVSNAM.Text = fssocket1.ServiceName
- End Sub
- Private Sub senddata (Text As String)
- On Error GoTo retry
- fssocket1.Send = Text
- Exit Sub
- retry:
- If fssocket1.WSALastError = 10035 Then
- RDYTOSND.Value = 0
- While RDYTOSND.Value = 0
- DoEvents
- Wend
- Else
- MsgBox fssocket1.WSALastErrorMsg
- Exit Sub
- End If
- Resume
- End Sub
- Private Sub SVSNAM_Change ()
- On Error Resume Next
- fssocket1.ServiceName = SVSNAM.Text
- PORTNUM.Text = fssocket1.PortNumber
- End Sub
- Private Sub TCP_Click ()
- fssocket1.Protocol = 0
- End Sub
- Private Sub UDP_Click ()
- fssocket1.Protocol = 1
- End Sub
-