home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Server
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "Server Test"
- ClientHeight = 6915
- ClientLeft = 7860
- ClientTop = 1620
- ClientWidth = 6960
- ControlBox = 0 'False
- Height = 7320
- Icon = 0
- Left = 7800
- LinkTopic = "Form1"
- ScaleHeight = 6915
- ScaleWidth = 6960
- Top = 1275
- Width = 7080
- Begin TextBox Text2
- Height = 285
- Left = 120
- TabIndex = 25
- Top = 6360
- Width = 855
- End
- Begin TextBox Text1
- Height = 285
- Left = 120
- TabIndex = 24
- Top = 6000
- Width = 855
- End
- Begin TextBox HSTNAME
- Height = 285
- Left = 120
- TabIndex = 22
- Top = 2040
- Width = 2175
- End
- Begin CommandButton Connect
- Caption = "Connect"
- Enabled = 0 'False
- Height = 375
- Left = 1080
- TabIndex = 21
- Top = 6000
- Width = 1215
- End
- Begin TextBox localaddress
- Height = 285
- Left = 120
- TabIndex = 18
- Top = 3840
- Width = 2175
- End
- Begin TextBox localport
- Height = 285
- Left = 120
- TabIndex = 17
- Top = 4440
- Width = 2175
- End
- Begin FSSocket FSSocket1
- Connect = 0 'False
- EOL = ""
- HostAddress = ""
- HostName = ""
- InputBufferSize = 8192
- Left = 1920
- Listen = 0 'False
- ListenPort = 0
- OutputBufferSize= 8192
- PortNumber = 0
- Protocol = 0 'TCP
- ServiceName = ""
- Top = 960
- End
- Begin CommandButton StopListenButt
- Caption = "Stop Listen"
- Enabled = 0 'False
- Height = 375
- Left = 1080
- TabIndex = 16
- Top = 5640
- Width = 1215
- End
- Begin CheckBox ListenMark
- BackColor = &H00C0C0C0&
- Caption = "Listening"
- Height = 255
- Left = 120
- TabIndex = 15
- Top = 4920
- Width = 1215
- End
- Begin TextBox LPText
- Height = 285
- Left = 120
- TabIndex = 3
- Top = 5640
- Width = 855
- End
- Begin CommandButton DisconnButt
- Caption = "Disconnect"
- Enabled = 0 'False
- Height = 375
- Left = 1080
- TabIndex = 5
- Top = 6360
- Width = 1215
- End
- Begin TextBox INDATA
- Height = 6375
- Left = 2400
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 10
- TabStop = 0 'False
- Top = 0
- Width = 4575
- End
- Begin TextBox OUTDATA
- Height = 285
- Left = 3120
- TabIndex = 6
- Top = 6465
- Width = 3735
- End
- Begin CommandButton ListenButt
- Caption = "Listen"
- Height = 375
- Left = 1080
- TabIndex = 4
- Top = 5280
- Width = 1215
- End
- Begin OptionButton UDP
- BackColor = &H00C0C0C0&
- Caption = "UDP"
- Height = 255
- Left = 105
- TabIndex = 9
- Top = 1320
- Width = 1095
- End
- Begin OptionButton TCP
- BackColor = &H00C0C0C0&
- Caption = "TCP"
- Height = 255
- Left = 120
- TabIndex = 1
- Top = 960
- Value = -1 'True
- Width = 1095
- End
- Begin TextBox HSTADDR
- Height = 285
- Left = 120
- TabIndex = 8
- TabStop = 0 'False
- Top = 2640
- Width = 2175
- End
- Begin TextBox PORTNUM
- Height = 285
- Left = 120
- TabIndex = 2
- TabStop = 0 'False
- Top = 3240
- Width = 2175
- End
- Begin CheckBox CNTD
- BackColor = &H00C0C0C0&
- Caption = "Connected"
- Height = 255
- Left = 120
- TabIndex = 7
- TabStop = 0 'False
- Top = 480
- Width = 1455
- End
- Begin CheckBox RDYTOSND
- BackColor = &H00C0C0C0&
- Caption = "Ready to Send"
- Height = 255
- Left = 120
- TabIndex = 0
- TabStop = 0 'False
- Top = 120
- Width = 1695
- End
- Begin Label Label5
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Remote Name"
- Height = 195
- Left = 120
- TabIndex = 23
- Top = 1800
- Width = 1200
- End
- Begin Label Label6
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Local Address"
- Height = 195
- Left = 120
- TabIndex = 20
- Top = 3600
- Width = 1215
- End
- Begin Label Label7
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Local Port"
- Height = 195
- Left = 120
- TabIndex = 19
- Top = 4200
- Width = 885
- End
- Begin Label Label2
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Port"
- Height = 195
- Left = 120
- TabIndex = 13
- Top = 5400
- Width = 360
- End
- Begin Label Label1
- Alignment = 1 'Right Justify
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Input:"
- Height = 255
- Left = 2520
- TabIndex = 14
- Top = 6480
- Width = 510
- End
- Begin Label Label3
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Remote Address"
- Height = 195
- Left = 120
- TabIndex = 12
- Top = 2400
- Width = 1395
- End
- Begin Label Label4
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "Remote Port"
- Height = 195
- Left = 120
- TabIndex = 11
- Top = 3000
- Width = 1065
- End
- Begin Line Line2
- X1 = 2400
- X2 = 0
- Y1 = 840
- Y2 = 840
- End
- Begin Line Line1
- X1 = 2400
- X2 = 2400
- Y1 = 0
- Y2 = 6960
- End
- Private Sub Connect_Click ()
- On Error GoTo errz
- fssocket1.ListenPort = LPText.Text
- fssocket1.Connect = True
- LocalAddress.Text = fssocket1.LocalAddress
- LocalPort.Text = fssocket1.LocalPort
- StopListenButt.Enabled = False
- ListenButt.Enabled = False
- DisconnButt.Enabled = True
- Exit Sub
- errz:
- MsgBox fssocket1.WSALastErrorMsg
- Resume Next
- End Sub
- Private Sub DisconnButt_Click ()
- fssocket1.Connect = False
- End Sub
- Private Sub Form_Load ()
- Show
- fssocket1.EOL = Chr$(10)
- INDATA.Text = ""
- OUTDATA.Text = ""
- hstaddr.Text = fssocket1.HostAddress
- HSTNAME.Text = fssocket1.HostName
- PORTNUM.Text = fssocket1.PortNumber
- LPText.Text = fssocket1.ListenPort
- If fssocket1.Protocol = 0 Then
- TCP.Value = True
- Else
- UDP.Value = True
- End If
- End Sub
- Private Sub FSSocket1_Connected (StatusCode As Integer, Description As String)
- CNTD.Value = 1
- RDYTOSND.Value = 1
- PORTNUM.Text = fssocket1.PortNumber
- hstaddr.Text = fssocket1.HostAddress
- HSTNAME.Text = fssocket1.HostName
- LocalAddress.Text = fssocket1.LocalAddress
- LocalPort.Text = fssocket1.LocalPort
- ListenMark.Value = 0
- DisconnButt.Enabled = True
- StopListenButt.Enabled = False
- 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)
- LocalAddress.Text = ""
- LocalPort.Text = ""
- CNTD.Value = 0
- RDYTOSND.Value = 0
- PORTNUM.Text = ""
- hstaddr.Text = ""
- HSTNAME.Text = ""
- If fssocket1.Listen = False Then
- ListenMark.Value = 0
- StopListenButt.Enabled = False
- Else
- ListenMark.Value = 1
- StopListenButt.Enabled = True
- End If
- DisconnButt.Enabled = False
- End Sub
- Private Sub FSSocket1_ReadyToSend ()
- RDYTOSND.Value = 1
- End Sub
- Private Sub ListenButt_Click ()
- On Error GoTo errx
- fssocket1.ListenPort = LPText.Text
- fssocket1.Listen = True
- LPText.Text = fssocket1.ListenPort
- text1.Text = fssocket1.ListenPort \ 256
- text2.Text = fssocket1.ListenPort Mod 256
- StopListenButt.Enabled = True
- ListenButt.Enabled = False
- DisconnButt.Enabled = False
- If fssocket1.Listen = False Then
- ListenMark.Value = 0
- Else
- ListenMark.Value = 1
- End If
- Exit Sub
- errx:
- MsgBox "Error number " & Err & " occurred at line " & Erl
- MsgBox fssocket1.WSALastErrorMsg
- Resume Next
- 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 StopListenButt_Click ()
- fssocket1.Listen = False
- If fssocket1.Listen = False Then
- ListenMark.Value = 0
- Else
- ListenMark.Value = 1
- End If
- ListenButt.Enabled = True
- StopListenButt.Enabled = False
- DisconnButt.Enabled = False
- End Sub
- Private Sub TCP_Click ()
- fssocket1.Protocol = 0
- ListenButt.Enabled = True
- StopListenButt.Enabled = False
- Connect.Enabled = False
- End Sub
- Private Sub UDP_Click ()
- fssocket1.Protocol = 1
- ListenButt.Enabled = False
- StopListenButt.Enabled = False
- Connect.Enabled = True
- End Sub
-