home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / program / vbkontrol.exe / CSWSK10A.ZIP / udpecho.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-25  |  3.6 KB  |  127 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3645
  5.    ClientLeft      =   2565
  6.    ClientTop       =   2280
  7.    ClientWidth     =   5685
  8.    Height          =   4050
  9.    Left            =   2505
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3645
  12.    ScaleWidth      =   5685
  13.    Top             =   1935
  14.    Width           =   5805
  15.    Begin Socket Socket1 
  16.       Backlog         =   1
  17.       Binary          =   -1  'True
  18.       Blocking        =   -1  'True
  19.       Broadcast       =   0   'False
  20.       BufferSize      =   0
  21.       HostAddress     =   ""
  22.       HostFile        =   ""
  23.       HostName        =   ""
  24.       InLine          =   0   'False
  25.       Interval        =   0
  26.       KeepAlive       =   0   'False
  27.       Left            =   1680
  28.       Linger          =   0
  29.       LocalPort       =   0
  30.       LocalService    =   ""
  31.       Peek            =   0   'False
  32.       Protocol        =   0
  33.       RecvLen         =   0
  34.       RemotePort      =   0
  35.       RemoteService   =   ""
  36.       ReuseAddress    =   0   'False
  37.       Route           =   -1  'True
  38.       SendLen         =   0
  39.       TabIndex        =   5
  40.       Timeout         =   0
  41.       Top             =   3120
  42.       Type            =   1
  43.       Urgent          =   0   'False
  44.    End
  45.    Begin CommandButton Command1 
  46.       Caption         =   "Close"
  47.       Height          =   375
  48.       Left            =   2400
  49.       TabIndex        =   4
  50.       Top             =   3120
  51.       Width           =   1215
  52.    End
  53.    Begin TextBox Text1 
  54.       Height          =   285
  55.       Left            =   240
  56.       TabIndex        =   3
  57.       Top             =   2640
  58.       Width           =   5175
  59.    End
  60.    Begin TextBox HostName 
  61.       Height          =   285
  62.       Left            =   960
  63.       TabIndex        =   1
  64.       Top             =   240
  65.       Width           =   4455
  66.    End
  67.    Begin ListBox List1 
  68.       Height          =   1980
  69.       Left            =   240
  70.       TabIndex        =   2
  71.       Top             =   600
  72.       Width           =   5175
  73.    End
  74.    Begin Label Label1 
  75.       AutoSize        =   -1  'True
  76.       BackStyle       =   0  'Transparent
  77.       Caption         =   "&System:"
  78.       Height          =   195
  79.       Left            =   240
  80.       TabIndex        =   0
  81.       Top             =   240
  82.       Width           =   675
  83.    End
  84. Option Explicit
  85. Sub Command1_Click ()
  86.     Unload Me
  87. End Sub
  88. Sub Form_Load ()
  89.     '
  90.     ' Initialize the socket control
  91.     '
  92.     Socket1.AddressFamily = AF_INET
  93.     Socket1.Binary = True
  94.     Socket1.Blocking = False
  95.     Socket1.Protocol = IPPROTO_IP
  96.     Socket1.Type = SOCK_DGRAM
  97.     Socket1.LocalPort = IPPORT_ECHO
  98.     Socket1.RemotePort = IPPORT_ECHO
  99.     Socket1.Action = SOCKET_OPEN
  100. End Sub
  101. Sub Form_Unload (Cancel As Integer)
  102.     If Socket1.Handle <> -1 Then Socket1.Action = SOCKET_CLOSE
  103. End Sub
  104. Sub HostName_GotFocus ()
  105.     HostName.SelStart = 0
  106.     HostName.SelLength = Len(HostName.Text)
  107. End Sub
  108. Sub Socket1_Error (ErrCode As Integer, ErrMsg As String, Response As Integer)
  109.     MsgBox ErrMsg
  110. End Sub
  111. Sub Socket1_Read (DataLength As Integer, IsUrgent As Integer)
  112.     Socket1.RecvLen = DataLength
  113.     List1.AddItem Socket1.RecvData
  114.     List1.ListIndex = List1.ListCount - 1
  115.     List1.Selected(List1.ListIndex) = False
  116. End Sub
  117. Sub Text1_KeyPress (KeyAscii As Integer)
  118.     If KeyAscii = 13 Then
  119.         On Error Resume Next
  120.         Socket1.HostName = Trim$(HostName.Text)
  121.         If Err <> 0 Then Exit Sub
  122.         Socket1.SendLen = Len(Text1.Text)
  123.         Socket1.SendData = Text1.Text
  124.         Text1.Text = "": KeyAscii = 0
  125.     End If
  126. End Sub
  127.