home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / fssock20 / client.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-11-20  |  11.3 KB  |  402 lines

  1. VERSION 2.00
  2. Begin Form client 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Client Test"
  6.    ClientHeight    =   6240
  7.    ClientLeft      =   585
  8.    ClientTop       =   1620
  9.    ClientWidth     =   6960
  10.    Height          =   6645
  11.    Icon            =   0
  12.    Left            =   525
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   6240
  15.    ScaleWidth      =   6960
  16.    Top             =   1275
  17.    Width           =   7080
  18.    Begin TextBox localport 
  19.       Height          =   285
  20.       Left            =   120
  21.       TabIndex        =   22
  22.       Top             =   4920
  23.       Width           =   2175
  24.    End
  25.    Begin TextBox localaddress 
  26.       Height          =   285
  27.       Left            =   120
  28.       TabIndex        =   21
  29.       Top             =   4320
  30.       Width           =   2175
  31.    End
  32.    Begin FSSocket FSSocket1 
  33.       Connect         =   0   'False
  34.       EOL             =   ""
  35.       HostAddress     =   "127.0.0.1"
  36.       HostName        =   "localhost"
  37.       InputBufferSize =   8192
  38.       Left            =   1785
  39.       Listen          =   0   'False
  40.       ListenPort      =   0
  41.       OutputBufferSize=   8192
  42.       PortNumber      =   0
  43.       Protocol        =   0  'TCP
  44.       ServiceName     =   ""
  45.       Top             =   1065
  46.    End
  47.    Begin CommandButton Command4 
  48.       Caption         =   "Set"
  49.       Height          =   255
  50.       Left            =   1800
  51.       TabIndex        =   6
  52.       Top             =   2520
  53.       Width           =   495
  54.    End
  55.    Begin CommandButton Command3 
  56.       Caption         =   "Set"
  57.       Height          =   255
  58.       Left            =   1800
  59.       TabIndex        =   4
  60.       Top             =   1920
  61.       Width           =   495
  62.    End
  63.    Begin CommandButton Command2 
  64.       Caption         =   "Disconnect"
  65.       Enabled         =   0   'False
  66.       Height          =   375
  67.       Left            =   1080
  68.       TabIndex        =   10
  69.       Top             =   5760
  70.       Width           =   1215
  71.    End
  72.    Begin TextBox SVSNAM 
  73.       Height          =   285
  74.       Left            =   120
  75.       TabIndex        =   8
  76.       Top             =   3720
  77.       Width           =   2175
  78.    End
  79.    Begin TextBox PORTNUM 
  80.       Height          =   285
  81.       Left            =   120
  82.       TabIndex        =   7
  83.       Top             =   3120
  84.       Width           =   2175
  85.    End
  86.    Begin TextBox HSTADDR 
  87.       Height          =   285
  88.       Left            =   120
  89.       TabIndex        =   5
  90.       Top             =   2520
  91.       Width           =   1575
  92.    End
  93.    Begin OptionButton TCP 
  94.       BackColor       =   &H00C0C0C0&
  95.       Caption         =   "TCP"
  96.       Height          =   255
  97.       Left            =   120
  98.       TabIndex        =   1
  99.       Top             =   960
  100.       Value           =   -1  'True
  101.       Width           =   1095
  102.    End
  103.    Begin OptionButton UDP 
  104.       BackColor       =   &H00C0C0C0&
  105.       Caption         =   "UDP"
  106.       Height          =   255
  107.       Left            =   120
  108.       TabIndex        =   2
  109.       Top             =   1320
  110.       Width           =   1095
  111.    End
  112.    Begin TextBox HSTNAM 
  113.       Height          =   285
  114.       Left            =   120
  115.       TabIndex        =   3
  116.       Top             =   1920
  117.       Width           =   1575
  118.    End
  119.    Begin CheckBox RDYTOSND 
  120.       BackColor       =   &H00C0C0C0&
  121.       Caption         =   "Ready to Send"
  122.       Height          =   255
  123.       Left            =   120
  124.       TabIndex        =   14
  125.       TabStop         =   0   'False
  126.       Top             =   120
  127.       Width           =   1695
  128.    End
  129.    Begin CheckBox CNTD 
  130.       BackColor       =   &H00C0C0C0&
  131.       Caption         =   "Connected"
  132.       Height          =   255
  133.       Left            =   120
  134.       TabIndex        =   13
  135.       TabStop         =   0   'False
  136.       Top             =   480
  137.       Width           =   1455
  138.    End
  139.    Begin CommandButton Command1 
  140.       Caption         =   "Connect"
  141.       Height          =   375
  142.       Left            =   1080
  143.       TabIndex        =   9
  144.       Top             =   5400
  145.       Width           =   1215
  146.    End
  147.    Begin TextBox OUTDATA 
  148.       Height          =   285
  149.       Left            =   3105
  150.       TabIndex        =   0
  151.       Top             =   5880
  152.       Width           =   3735
  153.    End
  154.    Begin TextBox INDATA 
  155.       Height          =   5775
  156.       Left            =   2400
  157.       MultiLine       =   -1  'True
  158.       ScrollBars      =   3  'Both
  159.       TabIndex        =   11
  160.       TabStop         =   0   'False
  161.       Top             =   -15
  162.       Width           =   4575
  163.    End
  164.    Begin Label Label7 
  165.       AutoSize        =   -1  'True
  166.       BackStyle       =   0  'Transparent
  167.       Caption         =   "Local Port"
  168.       Height          =   195
  169.       Left            =   120
  170.       TabIndex        =   20
  171.       Top             =   4680
  172.       Width           =   885
  173.    End
  174.    Begin Label Label6 
  175.       AutoSize        =   -1  'True
  176.       BackStyle       =   0  'Transparent
  177.       Caption         =   "Local Address"
  178.       Height          =   195
  179.       Left            =   120
  180.       TabIndex        =   19
  181.       Top             =   4080
  182.       Width           =   1215
  183.    End
  184.    Begin Label Label5 
  185.       AutoSize        =   -1  'True
  186.       BackStyle       =   0  'Transparent
  187.       Caption         =   "Service"
  188.       Height          =   195
  189.       Left            =   120
  190.       TabIndex        =   18
  191.       Top             =   3480
  192.       Width           =   660
  193.    End
  194.    Begin Label Label4 
  195.       AutoSize        =   -1  'True
  196.       BackStyle       =   0  'Transparent
  197.       Caption         =   "Port"
  198.       Height          =   195
  199.       Left            =   120
  200.       TabIndex        =   17
  201.       Top             =   2880
  202.       Width           =   360
  203.    End
  204.    Begin Line Line2 
  205.       X1              =   2400
  206.       X2              =   2400
  207.       Y1              =   0
  208.       Y2              =   6240
  209.    End
  210.    Begin Line Line1 
  211.       X1              =   0
  212.       X2              =   2400
  213.       Y1              =   840
  214.       Y2              =   840
  215.    End
  216.    Begin Label Label3 
  217.       AutoSize        =   -1  'True
  218.       BackStyle       =   0  'Transparent
  219.       Caption         =   "HostAddress"
  220.       Height          =   195
  221.       Left            =   120
  222.       TabIndex        =   16
  223.       Top             =   2280
  224.       Width           =   1080
  225.    End
  226.    Begin Label Label2 
  227.       AutoSize        =   -1  'True
  228.       BackStyle       =   0  'Transparent
  229.       Caption         =   "HostName"
  230.       Height          =   195
  231.       Left            =   120
  232.       TabIndex        =   15
  233.       Top             =   1680
  234.       Width           =   885
  235.    End
  236.    Begin Label Label1 
  237.       Alignment       =   1  'Right Justify
  238.       AutoSize        =   -1  'True
  239.       BackStyle       =   0  'Transparent
  240.       Caption         =   "Input:"
  241.       Height          =   255
  242.       Left            =   2520
  243.       TabIndex        =   12
  244.       Top             =   5880
  245.       Width           =   510
  246.    End
  247. Dim lastchanged As Integer
  248. Private Sub Command1_Click ()
  249.     fssocket1.EOL = Chr$(10)
  250.     On Error GoTo errx
  251.     fssocket1.Connect = True
  252.     LocalAddress.Text = fssocket1.LocalAddress
  253.     LocalPort.Text = fssocket1.LocalPort
  254.     If fssocket1.Protocol = 1 Then
  255.         command2.Enabled = True
  256.         command1.Enabled = False
  257.     End If
  258.     Exit Sub
  259. errx:
  260.     MsgBox fssocket1.WSALastErrorMsg
  261.     Resume Next
  262. End Sub
  263. Private Sub Command2_Click ()
  264.     fssocket1.Connect = False
  265.     LocalAddress.Text = ""
  266.     LocalPort.Text = ""
  267. End Sub
  268. Private Sub Command3_Click ()
  269.         On Error Resume Next
  270.         fssocket1.HostName = HSTNAM.Text
  271.         hstaddr.Text = fssocket1.HostAddress
  272. End Sub
  273. Private Sub Command4_Click ()
  274. On Error Resume Next
  275.         fssocket1.HostAddress = hstaddr.Text
  276.         HSTNAM.Text = fssocket1.HostName
  277. End Sub
  278. Private Sub Form_Load ()
  279.     INDATA.Text = ""
  280.     OUTDATA.Text = ""
  281.     HSTNAM.Text = fssocket1.HostName
  282.     hstaddr.Text = fssocket1.HostAddress
  283.     PORTNUM.Text = fssocket1.PortNumber
  284.     SVSNAM.Text = fssocket1.ServiceName
  285.     If fssocket1.Protocol = 0 Then
  286.         TCP.Value = True
  287.     Else
  288.         UDP.Value = True
  289.     End If
  290.     Load Server
  291.     lastchanged = 0
  292. End Sub
  293. Private Sub Form_Unload (Cancel As Integer)
  294.     Unload Server
  295. End Sub
  296. Private Sub FSSocket1_Connected (StatusCode As Integer, Description As String)
  297.     CNTD.Value = 1
  298.     RDYTOSND.Value = 1
  299.     command1.Enabled = False
  300.     command2.Enabled = True
  301.     LocalAddress.Text = fssocket1.LocalAddress
  302.     LocalPort.Text = fssocket1.LocalPort
  303. End Sub
  304. Private Sub FSSocket1_DataReceived (Text As String, EOL As Integer)
  305. Static fulstrng As String
  306.     fulstrng = fulstrng + Text
  307.     If EOL Then
  308.         INDATA.SelStart = 32000
  309.         INDATA.SelText = fulstrng & Chr$(13) & Chr$(10)
  310.         fulstrng = ""
  311.     End If
  312.     If fssocket1.Protocol = 1 Then
  313.         PORTNUM.Text = fssocket1.PortNumber
  314.         hstaddr.Text = fssocket1.HostAddress
  315.     End If
  316. End Sub
  317. Private Sub FSSocket1_Disconnected (StatusCode As Integer, Description As String)
  318.     CNTD.Value = 0
  319.     RDYTOSND.Value = 0
  320.     command1.Enabled = True
  321.     command2.Enabled = False
  322.     LocalAddress.Text = ""
  323.     LocalPort.Text = ""
  324. End Sub
  325. Private Sub FSSocket1_ReadyToSend ()
  326.     RDYTOSND.Value = 1
  327. End Sub
  328. Private Sub HSTADDR_KeyPress (keyascii As Integer)
  329. On Error Resume Next
  330.     If keyascii = 13 Then
  331.         fssocket1.HostAddress = hstaddr.Text
  332.         HSTNAM.Text = fssocket1.HostName
  333.         keyascii = 0
  334.     End If
  335. End Sub
  336. Private Sub HSTNAM_KeyPress (keyascii As Integer)
  337.     On Error Resume Next
  338.     If keyascii = 13 Then
  339.         fssocket1.HostName = HSTNAM.Text
  340.         hstaddr.Text = fssocket1.HostAddress
  341.         keyascii = 0
  342.     End If
  343. End Sub
  344. Private Sub OUTDATA_KeyPress (keyascii As Integer)
  345. On Error GoTo cantsend
  346. Dim x As Integer
  347.     If keyascii = 13 Then
  348.         If fssocket1.Connect = True Then
  349.             If fssocket1.Protocol = 1 Then
  350.                 fssocket1.HostAddress = hstaddr.Text
  351.             End If
  352.             fssocket1.Send = OUTDATA.Text & Chr$(10)
  353.         End If
  354.         OUTDATA.Text = ""
  355.         keyascii = 0
  356.     End If
  357. Exit Sub
  358. cantsend:
  359.     If fssocket1.WSALastError = 10035 Then
  360.         RDYTOSND.Value = 0
  361.         While RDYTOSND.Value = 0
  362.             DoEvents
  363.         Wend
  364.     Else
  365.         MsgBox fssocket1.WSALastErrorMsg
  366.         Exit Sub
  367.     End If
  368.     Resume
  369. End Sub
  370. Private Sub PORTNUM_Change ()
  371. On Error Resume Next
  372.         fssocket1.PortNumber = PORTNUM.Text
  373.         SVSNAM.Text = fssocket1.ServiceName
  374. End Sub
  375. Private Sub senddata (Text As String)
  376. On Error GoTo retry
  377.     fssocket1.Send = Text
  378.     Exit Sub
  379. retry:
  380.     If fssocket1.WSALastError = 10035 Then
  381.         RDYTOSND.Value = 0
  382.         While RDYTOSND.Value = 0
  383.             DoEvents
  384.         Wend
  385.     Else
  386.         MsgBox fssocket1.WSALastErrorMsg
  387.         Exit Sub
  388.     End If
  389.     Resume
  390. End Sub
  391. Private Sub SVSNAM_Change ()
  392. On Error Resume Next
  393.         fssocket1.ServiceName = SVSNAM.Text
  394.         PORTNUM.Text = fssocket1.PortNumber
  395. End Sub
  396. Private Sub TCP_Click ()
  397.     fssocket1.Protocol = 0
  398. End Sub
  399. Private Sub UDP_Click ()
  400.     fssocket1.Protocol = 1
  401. End Sub
  402.