IT 421 – Client Server Programming for the month of December
Programming using visual basic 6.0 is not just creating designs and inserting codes into the controls, but also analyzing the codes to come up with the correct designs. This activity will enhance your analyzes skill and this activity will serve as your laboratory activity number 2. As much as the subject is concerned, it is assumed that the following systems contain client and server. Analyze the code and answer the questions that follow after it. This is individual.
CLIENT SERVER SYSTEMS Activity 2
Instructions:
- Create a vb project for Server system and another (separate) project for Client System.
- Add the tool/control Microsoft Winsock 6.0 in your toolbox from your project components.
- Drag the added control to your server and client project forms.
- Create the design as shown below, and input the codes.
SYSTEM 1
Controls Description
Label1 = Message to the client
Label2 = Message from the client
Text1 = txtSenderMsg
Text2 = txtReceiverMsg
Text1 Multiline = True
Text1 ScrollBars = Vertical
Text2 Multiline = True
Text2 ScrollBars = Vertical
Winsock1 = wsckServer
Command1 = cmdSend
Codes
Private Sub cmdSend_Click()
Dim msg As String
msg = txtSenderMsg
wsckServer.SendData msg
End Sub
Private Sub Form_Activate()
wsckServer.LocalPort = "1001" 'any number defined as a Port Number as same as in the Client Program
wsckServer.Listen
End Sub
Private Sub Form_Terminate()
wsckServer.Close
End Sub
Private Sub wsckServer_ConnectionRequest(ByVal requestID As Long)
If wsckServer.State <> sckClosed Then wsckServer.Close
wsckServer.Accept requestID
End Sub
Private Sub wsckServer_DataArrival(ByVal bytesTotal As Long)
Dim msg As String
wsckServer.GetData msg
txtReceiverMsg = msg
End Sub
SYSTEM 2
Controls Description
Label1 = Message to the Server
Label2 = Message from the server
Text1 = txtSenderMsg
Text2 = txtReceiverMsg
Text1 Multiline = True
Text1 ScrollBars = Vertical
Text2 Multiline = True
Text2 ScrollBars = Vertical
Winsock1 = wsckServer
Command1 = cmdSend
Codes
Private Sub optConnect_Click()
End Sub
Private Sub optDisConnect_Click()
wsckClient.Close
optConnect.Enabled = True
optDisconnect.Enabled = False
txtSenderMsg.Enabled = False: txtReceiverMsg.Enabled = False
End Sub
Private Sub Form_Activate()
wsckClient.RemoteHost = "192.168.1.138"
wsckClient.RemotePort = "1001
wsckClient.Connect
End Sub
Private Sub wsckClient_DataArrival(ByVal bytesTotal As Long)
Dim msg As String
wsckClient.GetData msg
txtReceiverMsg = msg
End Sub
Private Sub cmdSend_Click()
On Error GoTo last
wsckClient.SendData txtSenderMsg
Exit Sub
last:
If Err.Number = 40006 Then
MsgBox "Not connected, Try again"
End If
End Sub
Private Sub Form_Terminate()
wsckClient.Close
End Sub
Questions:
- Determine which is the Client System and the Server System from two systems presented above. Why? Justify your answer.
- From question 1, create the DESIGN (illustrate) for Client and for Server.
- Discuss how the controls and its equivalent descriptions being performed for the client and the server system. Example: Label1 = Message to the Client. Why does it set as shown, where should I perform it? E.g. design window mode, code window, property window, explorer window and etc. Step-by-step explanation is encouraged.
- Discuss the general performance of the systems. How these perform things. What’s the role of client to the server and vice versa?
- Discuss the scope of the systems. Is it specified command or user-defined command and etc.
No comments:
Post a Comment