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

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