home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "mswinsck.ocx"
- Begin VB.Form frmServer
- AutoRedraw = -1 'True
- Caption = "Information Server"
- ClientHeight = 4770
- ClientLeft = 165
- ClientTop = 450
- ClientWidth = 6810
- LinkTopic = "Form1"
- ScaleHeight = 4770
- ScaleWidth = 6810
- StartUpPosition = 3 'Windows Default
- Begin VB.Data Data1
- Caption = "Data1"
- Connect = "Access"
- DatabaseName = "C:\winsock\server\Inven.mdb"
- DefaultCursorType= 0 'DefaultCursor
- DefaultType = 2 'UseODBC
- Exclusive = 0 'False
- Height = 345
- Left = 600
- Options = 0
- ReadOnly = 0 'False
- RecordsetType = 1 'Dynaset
- RecordSource = "Products"
- Top = 4080
- Visible = 0 'False
- Width = 2655
- End
- Begin VB.ListBox List1
- Height = 1815
- Left = 120
- TabIndex = 5
- Top = 360
- Width = 6615
- End
- Begin VB.Frame Frame1
- Height = 1455
- Left = 120
- TabIndex = 0
- Top = 2400
- Width = 4095
- Begin VB.Label lblUsers
- Caption = "Connections"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 240
- TabIndex = 7
- Top = 960
- Width = 1455
- End
- Begin VB.Label lblConnections
- Height = 375
- Left = 1680
- TabIndex = 6
- Top = 960
- Width = 2175
- End
- Begin VB.Label lblAddress
- Height = 255
- Left = 1680
- TabIndex = 4
- Top = 600
- Width = 2055
- End
- Begin VB.Label lblHostID
- Height = 255
- Left = 1680
- TabIndex = 3
- Top = 240
- Width = 1935
- End
- Begin VB.Label lblIP
- Caption = "IP Address"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 240
- TabIndex = 2
- Top = 600
- Width = 1335
- End
- Begin VB.Label lblHostName
- Caption = "Host"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 240
- TabIndex = 1
- Top = 240
- Width = 1215
- End
- End
- Begin MSWinsockLib.Winsock Socket
- Index = 0
- Left = 4440
- Top = 3120
- _ExtentX = 741
- _ExtentY = 741
- _Version = 327681
- End
- Attribute VB_Name = "frmServer"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim iSockets As Integer
- Dim sServerMsg As String
- Dim sRequestID As String
- Private Sub cmdStop_Click()
- End Sub
- Private Sub Form_Load()
- '-------------------------------------------------------------------------------------
- ' Program : Server2.exe
- ' Author: Loren D.Eidahl
- ' Date : 2/31/98
- ' Notice: Copyright(c) 1998 CTS, Inc. and Loren D. Eidahl
- ' This product is supplied without support of any kind.
- ' Notes:
- '-----------------------------------------------------------------------------------
- frmServer.Show
- lblHostID.Caption = Socket(0).LocalHostName
- lblAddress.Caption = Socket(0).LocalIP
- Socket(0).LocalPort = 1007
- sServerMsg = "Listening to port: " & Socket(0).LocalPort
- List1.AddItem (sServerMsg)
- Socket(0).Listen
- End Sub
- Private Sub socket_Close(Index As Integer)
- sServerMsg = "Connection closed: " & Socket(Index).RemoteHostIP
- List1.AddItem (sServerMsg)
- Socket(Index).Close
- Unload Socket(Index)
- iSockets = iSockets - 1
- lblConnections.Caption = iSockets
- End Sub
- Private Sub socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
- sServerMsg = "Connection request id " & requestID & " from " & Socket(Index).RemoteHostIP
- If Index = 0 Then
- List1.AddItem (sServerMsg)
- sRequestID = requestID
- iSockets = iSockets + 1
- lblConnections.Caption = iSockets
- Load Socket(iSockets)
- Socket(iSockets).LocalPort = 1007
- Socket(iSockets).Accept requestID
- End If
- End Sub
- Private Sub socket_DataArrival(Index As Integer, ByVal bytesTotal As Long)
- Dim sItemData As String
- Dim strData As String
- Dim strOutData As String
-
- ' get data from client
- Socket(Index).GetData vtData, vbString
- sServerMsg = "Received: " & vtData & " from " & Socket(Index).RemoteHostIP & "(" & sRequestID & ")"
- List1.AddItem (sServerMsg)
- ' Get clients request from database
- strData = "ItemNumber = '" & sItemData & "'"
- Data1.Recordset.MoveLast
- Data1.Recordset.FindFirst strData
- strOutData = Data1.Recordset.Fields("Price")
- 'send data to client
- sServerMsg = "Sending: " & strOutData & " to " & Socket(Index).RemoteHostIP
- List1.AddItem (sServerMsg)
- Socket(Index).SendData strOutData
- End Sub
-