home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Unleashed
/
Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso
/
source
/
chap15
/
udpecho.frm
< prev
next >
Wrap
Text File
|
1995-07-01
|
4KB
|
136 lines
VERSION 2.00
Begin Form Form1
Caption = "Form1"
ClientHeight = 3645
ClientLeft = 2565
ClientTop = 2280
ClientWidth = 5685
Height = 4050
Left = 2505
LinkTopic = "Form1"
ScaleHeight = 3645
ScaleWidth = 5685
Top = 1935
Width = 5805
Begin Socket Socket1
Backlog = 1
Binary = -1 'True
Blocking = -1 'True
Broadcast = 0 'False
BufferSize = 0
HostAddress = ""
HostFile = ""
HostName = ""
InLine = 0 'False
Interval = 0
KeepAlive = 0 'False
Left = 1680
Linger = 0
LocalPort = 0
LocalService = ""
Peek = 0 'False
Protocol = 0
RecvLen = 0
RemotePort = 0
RemoteService = ""
ReuseAddress = 0 'False
Route = -1 'True
SendLen = 0
TabIndex = 5
Timeout = 0
Top = 3120
Type = 1
Urgent = 0 'False
End
Begin CommandButton Command1
Caption = "Close"
Height = 375
Left = 2400
TabIndex = 4
Top = 3120
Width = 1215
End
Begin TextBox Text1
Height = 285
Left = 240
TabIndex = 3
Top = 2640
Width = 5175
End
Begin TextBox HostName
Height = 285
Left = 960
TabIndex = 1
Top = 240
Width = 4455
End
Begin ListBox List1
Height = 1980
Left = 240
TabIndex = 2
Top = 600
Width = 5175
End
Begin Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "&System:"
Height = 195
Left = 240
TabIndex = 0
Top = 240
Width = 675
End
End
Option Explicit
Sub Command1_Click ()
Unload Me
End Sub
Sub Form_Load ()
'
' Initialize the socket control
'
Socket1.AddressFamily = AF_INET
Socket1.Binary = True
Socket1.Blocking = False
Socket1.Protocol = IPPROTO_IP
Socket1.Type = SOCK_DGRAM
Socket1.LocalPort = IPPORT_ECHO
Socket1.RemotePort = IPPORT_ECHO
Socket1.Action = SOCKET_OPEN
End Sub
Sub Form_Unload (Cancel As Integer)
If Socket1.Handle <> -1 Then Socket1.Action = SOCKET_CLOSE
End Sub
Sub HostName_GotFocus ()
HostName.SelStart = 0
HostName.SelLength = Len(HostName.Text)
End Sub
Sub Socket1_Error (ErrCode As Integer, ErrMsg As String, Response As Integer)
MsgBox ErrMsg
End Sub
Sub Socket1_Read (DataLength As Integer, IsUrgent As Integer)
Socket1.RecvLen = DataLength
List1.AddItem Socket1.RecvData
List1.ListIndex = List1.ListCount - 1
List1.Selected(List1.ListIndex) = False
End Sub
Sub Text1_KeyPress (KeyAscii As Integer)
If KeyAscii = 13 Then
On Error Resume Next
Socket1.HostName = Trim$(HostName.Text)
If Err <> 0 Then Exit Sub
Socket1.SendLen = Len(Text1.Text)
Socket1.SendData = Text1.Text
Text1.Text = "": KeyAscii = 0
End If
End Sub