Crystalinity
Technical User
I created a project composed of two executives - a server designed to run silently in the background and display message boxes at a signal from a client.
Server.exe is composed of:
AdvServer.frm:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 450
ClientLeft = 28515
ClientTop = 5925
ClientWidth = 1560
LinkTopic = "Form1"
ScaleHeight = 450
ScaleWidth = 1560
Visible = 0 'False
Begin MSWinsockLib.Winsock ServerSocket10
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1011
End
Begin MSWinsockLib.Winsock ServerSocket9
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1010
End
Begin MSWinsockLib.Winsock ServerSocket8
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1009
End
Begin MSWinsockLib.Winsock ServerSocket7
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1008
End
Begin MSWinsockLib.Winsock ServerSocket6
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1007
End
Begin MSWinsockLib.Winsock ServerSocket5
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1006
End
Begin MSWinsockLib.Winsock ServerSocket4
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1005
End
Begin MSWinsockLib.Winsock ServerSocket3
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1004
End
Begin MSWinsockLib.Winsock ServerSocket2
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1003
End
Begin MSWinsockLib.Winsock ServerSocket1
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1002
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
ServerSocket1.LocalPort = 1002
ServerSocket1.Listen
ServerSocket2.LocalPort = 1003
ServerSocket2.Listen
ServerSocket3.LocalPort = 1004
ServerSocket3.Listen
ServerSocket4.LocalPort = 1005
ServerSocket4.Listen
ServerSocket5.LocalPort = 1006
ServerSocket5.Listen
ServerSocket6.LocalPort = 1007
ServerSocket6.Listen
ServerSocket7.LocalPort = 1008
ServerSocket7.Listen
ServerSocket8.LocalPort = 1009
ServerSocket8.Listen
ServerSocket9.LocalPort = 1010
ServerSocket9.Listen
ServerSocket10.LocalPort = 1011
ServerSocket10.Listen
End Sub
Private Sub Form_Unload(Cancel As Integer)
If ServerSocket1.State <> sckClosed Then ServerSocket1.Close
If ServerSocket2.State <> sckClosed Then ServerSocket2.Close
If ServerSocket3.State <> sckClosed Then ServerSocket3.Close
If ServerSocket4.State <> sckClosed Then ServerSocket4.Close
If ServerSocket5.State <> sckClosed Then ServerSocket5.Close
If ServerSocket6.State <> sckClosed Then ServerSocket1.Close
If ServerSocket7.State <> sckClosed Then ServerSocket2.Close
If ServerSocket8.State <> sckClosed Then ServerSocket3.Close
If ServerSocket9.State <> sckClosed Then ServerSocket4.Close
If ServerSocket10.State <> sckClosed Then ServerSocket5.Close
End
End Sub
Private Sub ServerSocket2_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket2.State <> sckClosed Then ServerSocket2.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket2.Accept requestID
End Sub
Private Sub ServerSocket3_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket3.State <> sckClosed Then ServerSocket3.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket3.Accept requestID
End Sub
Private Sub ServerSocket4_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket4.State <> sckClosed Then ServerSocket4.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket4.Accept requestID
End Sub
Private Sub ServerSocket5_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket5.State <> sckClosed Then ServerSocket5.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket5.Accept requestID
End Sub
Private Sub ServerSocket6_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket6.State <> sckClosed Then ServerSocket6.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket6.Accept requestID
End Sub
Private Sub ServerSocket7_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket7.State <> sckClosed Then ServerSocket7.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket7.Accept requestID
End Sub
Private Sub ServerSocket8_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket8.State <> sckClosed Then ServerSocket8.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket8.Accept requestID
End Sub
Private Sub ServerSocket9_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket9.State <> sckClosed Then ServerSocket9.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket9.Accept requestID
End Sub
Private Sub ServerSocket10_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket10.State <> sckClosed Then ServerSocket10.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket10.Accept requestID
End Sub
Private Sub ServerSocket1_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket1.State <> sckClosed Then ServerSocket1.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket1.Accept requestID
End Sub
Private Sub ServerSocket2_DataArrival(ByVal bytesTotal As Long)
Dim str2 As String
ServerSocket2.GetData str2
End Sub
Private Sub ServerSocket3_DataArrival(ByVal bytesTotal As Long)
Dim str3 As String
ServerSocket3.GetData str3
End Sub
Private Sub ServerSocket4_DataArrival(ByVal bytesTotal As Long)
Dim str4 As String
ServerSocket4.GetData str4
End Sub
Private Sub ServerSocket5_DataArrival(ByVal bytesTotal As Long)
Dim str5 As String
ServerSocket5.GetData str5
End Sub
Private Sub ServerSocket6_DataArrival(ByVal bytesTotal As Long)
Dim str6 As String
ServerSocket6.GetData str6
End Sub
Private Sub ServerSocket7_DataArrival(ByVal bytesTotal As Long)
Dim str7 As String
ServerSocket7.GetData str7
End Sub
Private Sub ServerSocket8_DataArrival(ByVal bytesTotal As Long)
Dim str8 As String
ServerSocket8.GetData str8
End Sub
Private Sub ServerSocket9_DataArrival(ByVal bytesTotal As Long)
Dim str9 As String
ServerSocket9.GetData str9
End Sub
Private Sub ServerSocket10_DataArrival(ByVal bytesTotal As Long)
Dim str10 As String
ServerSocket10.GetData str10
End Sub
Private Sub ServerSocket1_DataArrival(ByVal bytesTotal As Long)
Dim str1 As String
ServerSocket1.GetData str1
Select Case str1
Case "Message":
MsgBox str2, str3, str4
End Select
End Sub
Client.exe is composed of:
Form1.frm:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
Caption = "Client"
ClientHeight = 6240
ClientLeft = 60
ClientTop = 345
ClientWidth = 6855
LinkTopic = "Form1"
ScaleHeight = 6240
ScaleWidth = 6855
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdMsgBox
Caption = "Send Message Box"
Enabled = 0 'False
Height = 615
Left = 120
TabIndex = 5
Top = 1680
Width = 1095
End
Begin VB.TextBox cmdOutput
Enabled = 0 'False
Height = 2055
Left = 120
MultiLine = -1 'True
TabIndex = 4
Text = "Form1.frx":0000
Top = 4080
Width = 6615
End
Begin VB.TextBox txtServer
Alignment = 2 'Center
Height = 375
Left = 960
TabIndex = 2
Text = "192.168.0.3"
Top = 720
Width = 2535
End
Begin VB.CommandButton cmdDisconnect
Caption = "&Disconnect"
Enabled = 0 'False
Height = 735
Left = 5160
TabIndex = 1
Top = 480
Width = 1455
End
Begin VB.CommandButton cmdConnect
Caption = "&Connect"
Height = 735
Left = 3720
TabIndex = 0
Top = 480
Width = 1455
End
Begin MSWinsockLib.Winsock Winsock10
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1011
End
Begin MSWinsockLib.Winsock Winsock9
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1010
End
Begin MSWinsockLib.Winsock Winsock8
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1009
End
Begin MSWinsockLib.Winsock Winsock7
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1008
End
Begin MSWinsockLib.Winsock Winsock6
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1007
End
Begin MSWinsockLib.Winsock Winsock5
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1006
End
Begin MSWinsockLib.Winsock Winsock4
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1005
End
Begin MSWinsockLib.Winsock Winsock3
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1004
End
Begin MSWinsockLib.Winsock Winsock2
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1003
End
Begin MSWinsockLib.Winsock Winsock1
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1002
End
Begin VB.Label Label1
Caption = "Server name/IP:"
Height = 375
Left = 240
TabIndex = 3
Top = 720
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public rcmd0, rcmd1, rcmd2, rcmd3, rcmd4, rcmd5, rcmd6, rcmd7, rcmd8, rcmd9 As Variant
Private Sub cmdConnect_Click()
Winsock1.RemoteHost = txtServer.Text
Winsock1.Connect
Winsock2.RemoteHost = txtServer.Text
Winsock2.Connect
Winsock3.RemoteHost = txtServer.Text
Winsock3.Connect
Winsock4.RemoteHost = txtServer.Text
Winsock4.Connect
Winsock5.RemoteHost = txtServer.Text
Winsock5.Connect
Winsock6.RemoteHost = txtServer.Text
Winsock6.Connect
Winsock7.RemoteHost = txtServer.Text
Winsock7.Connect
Winsock8.RemoteHost = txtServer.Text
Winsock8.Connect
Winsock9.RemoteHost = txtServer.Text
Winsock9.Connect
Winsock10.RemoteHost = txtServer.Text
Winsock10.Connect
cmdConnect.Enabled = False
cmdMsgBox.Enabled = True
cmdDisconnect.Enabled = True
txtServer.Enabled = True
MsgBox "Connection successful.", vbOKOnly + vbInformation, "Connection Status"
End Sub
Private Sub cmdDisconnect_Click()
If Winsock1.State <> sckClosed Then Winsock1.Close
If Winsock2.State <> sckClosed Then Winsock2.Close
If Winsock3.State <> sckClosed Then Winsock3.Close
If Winsock4.State <> sckClosed Then Winsock4.Close
If Winsock5.State <> sckClosed Then Winsock5.Close
If Winsock6.State <> sckClosed Then Winsock6.Close
If Winsock7.State <> sckClosed Then Winsock7.Close
If Winsock8.State <> sckClosed Then Winsock8.Close
If Winsock9.State <> sckClosed Then Winsock9.Close
If Winsock10.State <> sckClosed Then Winsock10.Close
cmdConnect.Enabled = True
cmdDisconnect.Enabled = False
cmdMsgBox.Enabled = False
MsgBox "Disconnection successful.", vbOKOnly + vbInformation, "Connection Status"
End Sub
Private Sub cmdMsgBox_Click()
frmMsgBox.Visible = True
Form1.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Winsock1.State <> sckClosed Then Winsock1.Close
If Winsock2.State <> sckClosed Then Winsock2.Close
If Winsock3.State <> sckClosed Then Winsock3.Close
If Winsock4.State <> sckClosed Then Winsock4.Close
If Winsock5.State <> sckClosed Then Winsock5.Close
If Winsock6.State <> sckClosed Then Winsock6.Close
If Winsock7.State <> sckClosed Then Winsock7.Close
If Winsock8.State <> sckClosed Then Winsock8.Close
If Winsock9.State <> sckClosed Then Winsock9.Close
If Winsock10.State <> sckClosed Then Winsock10.Close
Unload Me
End Sub
frmMsgBox.frm:
VERSION 5.00
Begin VB.Form frmMsgBox
BorderStyle = 3 'Fixed Dialog
Caption = "Choose Message Options"
ClientHeight = 3615
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 6030
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3615
ScaleWidth = 6030
ShowInTaskbar = 0 'False
Begin VB.CheckBox chkSysModal
Caption = "Urgent"
Enabled = 0 'False
Height = 495
Left = 4440
TabIndex = 17
Top = 1920
Width = 1335
End
Begin VB.OptionButton optMsgIcon
Caption = "Exclamation"
Enabled = 0 'False
Height = 375
Left = 2520
TabIndex = 15
Top = 2880
Width = 1215
End
Begin VB.OptionButton optMsgIcon3
Caption = "Critical"
Enabled = 0 'False
Height = 495
Left = 2520
TabIndex = 14
Top = 2400
Width = 855
End
Begin VB.OptionButton optMsgIcon2
Caption = "Question"
Enabled = 0 'False
Height = 375
Left = 2520
TabIndex = 13
Top = 2040
Width = 975
End
Begin VB.OptionButton optMsgIcon1
Caption = "Information"
Enabled = 0 'False
Height = 375
Left = 2520
TabIndex = 11
Top = 1560
Width = 1215
End
Begin VB.OptionButton optMsgType2
Caption = "OK only"
Height = 495
Left = 240
TabIndex = 7
Top = 1800
Width = 1575
End
Begin VB.OptionButton optMsgType1
Caption = "Abort, Retry, Ignore"
Height = 255
Left = 240
TabIndex = 6
Top = 1560
Width = 1695
End
Begin VB.TextBox txtMessage
Height = 375
Left = 1080
TabIndex = 5
Top = 720
Width = 3255
End
Begin VB.TextBox txtTitle
Height = 375
Left = 1080
TabIndex = 2
Top = 240
Width = 3255
End
Begin VB.CommandButton CancelButton
Caption = "Cancel"
Height = 375
Left = 4680
TabIndex = 1
Top = 600
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "OK"
Height = 375
Left = 4680
TabIndex = 0
Top = 120
Width = 1215
End
Begin VB.Frame Frame1
Caption = "MsgBox Style"
Height = 2175
Left = 120
TabIndex = 8
Top = 1320
Width = 2055
Begin VB.OptionButton optMsgType5
Caption = "Retry, Cancel"
Height = 255
Left = 120
TabIndex = 12
Top = 1800
Width = 1695
End
Begin VB.OptionButton optMsgType4
Caption = "Yes, No"
Height = 375
Left = 120
TabIndex = 10
Top = 1320
Width = 975
End
Begin VB.OptionButton optMsgType3
Caption = "OK, Cancel"
Height = 375
Left = 120
TabIndex = 9
Top = 960
Width = 1215
End
End
Begin VB.Frame Frame2
Caption = "MsgBox Icon"
Height = 2055
Left = 2400
TabIndex = 16
Top = 1320
Width = 1575
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "&Message:"
Height = 255
Left = 120
TabIndex = 4
Top = 720
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "&Title:"
Height = 255
Left = 360
TabIndex = 3
Top = 360
Width = 855
End
End
Attribute VB_Name = "frmMsgBox"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim checked As Integer
Public rcmd20, rcmd21, rcmd22, rcmd23, rcmd24, rcmd25, rcmd26, rcmd27, rcmd28, rcmd29 As Variant
Private Sub CancelButton_Click()
frmMsgBox.Visible = False
End Sub
Private Sub chkSysModal_Click()
If checked = 0 Then
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
optMsgIcon.Enabled = False
optMsgIcon1.Enabled = False
optMsgIcon2.Enabled = False
optMsgIcon3.Enabled = False
rcmd21 = rcmd21 + vbSystemModal
checked = 1
Else
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
optMsgIcon.Enabled = False
optMsgIcon1.Enabled = False
optMsgIcon2.Enabled = False
optMsgIcon3.Enabled = False
rcmd21 = rcmd21 - vbSystemModal
End If
End Sub
Private Sub Form_Load()
checked = 0
End Sub
Private Sub OKButton_Click()
rcmd20 = txtMessage.Text
rcmd22 = txtTitle.Text
Form1.rcmd0 = rcmd20
Form1.rcmd1 = rcmd21
Form1.rcmd2 = rcmd22
Form1.Winsock2.SendData Form1.rcmd0
Form1.Winsock3.SendData Form1.rcmd1
Form1.Winsock4.SendData Form1.rcmd2
Form1.Winsock1.SendData "Message"
frmMsgBox.Visible = False
Form1.Enabled = True
End Sub
Private Sub optMsgIcon_Click()
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
chkSysModal.Enabled = True
rcmd21 = rcmd21 + vbExclamation
End Sub
Private Sub optMsgIcon1_Click()
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
chkSysModal.Enabled = True
rcmd21 = rcmd21 + vbInformation
End Sub
Private Sub optMsgIcon2_Click()
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
chkSysModal.Enabled = True
rcmd21 = rcmd21 + vbQuestion
End Sub
Private Sub optMsgIcon3_Click()
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
chkSysModal.Enabled = True
rcmd21 = rcmd21 + vbCritical
End Sub
Private Sub optMsgType1_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbAbortRetryIgnore
End Sub
Private Sub optMsgType2_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbOKOnly
End Sub
Private Sub optMsgType3_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbAbortRetryIgnore
End Sub
Private Sub optMsgType4_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbYesNo
End Sub
Private Sub optMsgType5_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbRetryCancel
End Sub
When I send the Message data from client to server, apparently port 1002 gets through, but none of the others do, as I get a blank message box which is not system modal, whatever I put in.
Why?
Please help,
Crystalinity
P.S. Could anyone tell me how to differentiate between arguments at the server from a single string, even if you don't know how long the arguments will be? This would help to make the program one hell of a lot shorter.
Server.exe is composed of:
AdvServer.frm:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 450
ClientLeft = 28515
ClientTop = 5925
ClientWidth = 1560
LinkTopic = "Form1"
ScaleHeight = 450
ScaleWidth = 1560
Visible = 0 'False
Begin MSWinsockLib.Winsock ServerSocket10
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1011
End
Begin MSWinsockLib.Winsock ServerSocket9
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1010
End
Begin MSWinsockLib.Winsock ServerSocket8
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1009
End
Begin MSWinsockLib.Winsock ServerSocket7
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1008
End
Begin MSWinsockLib.Winsock ServerSocket6
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1007
End
Begin MSWinsockLib.Winsock ServerSocket5
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1006
End
Begin MSWinsockLib.Winsock ServerSocket4
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1005
End
Begin MSWinsockLib.Winsock ServerSocket3
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1004
End
Begin MSWinsockLib.Winsock ServerSocket2
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1003
End
Begin MSWinsockLib.Winsock ServerSocket1
Left = 480
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
LocalPort = 1002
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
ServerSocket1.LocalPort = 1002
ServerSocket1.Listen
ServerSocket2.LocalPort = 1003
ServerSocket2.Listen
ServerSocket3.LocalPort = 1004
ServerSocket3.Listen
ServerSocket4.LocalPort = 1005
ServerSocket4.Listen
ServerSocket5.LocalPort = 1006
ServerSocket5.Listen
ServerSocket6.LocalPort = 1007
ServerSocket6.Listen
ServerSocket7.LocalPort = 1008
ServerSocket7.Listen
ServerSocket8.LocalPort = 1009
ServerSocket8.Listen
ServerSocket9.LocalPort = 1010
ServerSocket9.Listen
ServerSocket10.LocalPort = 1011
ServerSocket10.Listen
End Sub
Private Sub Form_Unload(Cancel As Integer)
If ServerSocket1.State <> sckClosed Then ServerSocket1.Close
If ServerSocket2.State <> sckClosed Then ServerSocket2.Close
If ServerSocket3.State <> sckClosed Then ServerSocket3.Close
If ServerSocket4.State <> sckClosed Then ServerSocket4.Close
If ServerSocket5.State <> sckClosed Then ServerSocket5.Close
If ServerSocket6.State <> sckClosed Then ServerSocket1.Close
If ServerSocket7.State <> sckClosed Then ServerSocket2.Close
If ServerSocket8.State <> sckClosed Then ServerSocket3.Close
If ServerSocket9.State <> sckClosed Then ServerSocket4.Close
If ServerSocket10.State <> sckClosed Then ServerSocket5.Close
End
End Sub
Private Sub ServerSocket2_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket2.State <> sckClosed Then ServerSocket2.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket2.Accept requestID
End Sub
Private Sub ServerSocket3_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket3.State <> sckClosed Then ServerSocket3.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket3.Accept requestID
End Sub
Private Sub ServerSocket4_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket4.State <> sckClosed Then ServerSocket4.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket4.Accept requestID
End Sub
Private Sub ServerSocket5_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket5.State <> sckClosed Then ServerSocket5.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket5.Accept requestID
End Sub
Private Sub ServerSocket6_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket6.State <> sckClosed Then ServerSocket6.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket6.Accept requestID
End Sub
Private Sub ServerSocket7_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket7.State <> sckClosed Then ServerSocket7.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket7.Accept requestID
End Sub
Private Sub ServerSocket8_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket8.State <> sckClosed Then ServerSocket8.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket8.Accept requestID
End Sub
Private Sub ServerSocket9_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket9.State <> sckClosed Then ServerSocket9.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket9.Accept requestID
End Sub
Private Sub ServerSocket10_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket10.State <> sckClosed Then ServerSocket10.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket10.Accept requestID
End Sub
Private Sub ServerSocket1_ConnectionRequest(ByVal requestID As Long)
' Close the connection if it is currently open
' by testing the State property.
If ServerSocket1.State <> sckClosed Then ServerSocket1.Close
' Pass the value of the requestID parameter to the
' Accept method.
ServerSocket1.Accept requestID
End Sub
Private Sub ServerSocket2_DataArrival(ByVal bytesTotal As Long)
Dim str2 As String
ServerSocket2.GetData str2
End Sub
Private Sub ServerSocket3_DataArrival(ByVal bytesTotal As Long)
Dim str3 As String
ServerSocket3.GetData str3
End Sub
Private Sub ServerSocket4_DataArrival(ByVal bytesTotal As Long)
Dim str4 As String
ServerSocket4.GetData str4
End Sub
Private Sub ServerSocket5_DataArrival(ByVal bytesTotal As Long)
Dim str5 As String
ServerSocket5.GetData str5
End Sub
Private Sub ServerSocket6_DataArrival(ByVal bytesTotal As Long)
Dim str6 As String
ServerSocket6.GetData str6
End Sub
Private Sub ServerSocket7_DataArrival(ByVal bytesTotal As Long)
Dim str7 As String
ServerSocket7.GetData str7
End Sub
Private Sub ServerSocket8_DataArrival(ByVal bytesTotal As Long)
Dim str8 As String
ServerSocket8.GetData str8
End Sub
Private Sub ServerSocket9_DataArrival(ByVal bytesTotal As Long)
Dim str9 As String
ServerSocket9.GetData str9
End Sub
Private Sub ServerSocket10_DataArrival(ByVal bytesTotal As Long)
Dim str10 As String
ServerSocket10.GetData str10
End Sub
Private Sub ServerSocket1_DataArrival(ByVal bytesTotal As Long)
Dim str1 As String
ServerSocket1.GetData str1
Select Case str1
Case "Message":
MsgBox str2, str3, str4
End Select
End Sub
Client.exe is composed of:
Form1.frm:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
Caption = "Client"
ClientHeight = 6240
ClientLeft = 60
ClientTop = 345
ClientWidth = 6855
LinkTopic = "Form1"
ScaleHeight = 6240
ScaleWidth = 6855
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdMsgBox
Caption = "Send Message Box"
Enabled = 0 'False
Height = 615
Left = 120
TabIndex = 5
Top = 1680
Width = 1095
End
Begin VB.TextBox cmdOutput
Enabled = 0 'False
Height = 2055
Left = 120
MultiLine = -1 'True
TabIndex = 4
Text = "Form1.frx":0000
Top = 4080
Width = 6615
End
Begin VB.TextBox txtServer
Alignment = 2 'Center
Height = 375
Left = 960
TabIndex = 2
Text = "192.168.0.3"
Top = 720
Width = 2535
End
Begin VB.CommandButton cmdDisconnect
Caption = "&Disconnect"
Enabled = 0 'False
Height = 735
Left = 5160
TabIndex = 1
Top = 480
Width = 1455
End
Begin VB.CommandButton cmdConnect
Caption = "&Connect"
Height = 735
Left = 3720
TabIndex = 0
Top = 480
Width = 1455
End
Begin MSWinsockLib.Winsock Winsock10
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1011
End
Begin MSWinsockLib.Winsock Winsock9
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1010
End
Begin MSWinsockLib.Winsock Winsock8
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1009
End
Begin MSWinsockLib.Winsock Winsock7
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1008
End
Begin MSWinsockLib.Winsock Winsock6
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1007
End
Begin MSWinsockLib.Winsock Winsock5
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1006
End
Begin MSWinsockLib.Winsock Winsock4
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1005
End
Begin MSWinsockLib.Winsock Winsock3
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1004
End
Begin MSWinsockLib.Winsock Winsock2
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1003
End
Begin MSWinsockLib.Winsock Winsock1
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemotePort = 1002
End
Begin VB.Label Label1
Caption = "Server name/IP:"
Height = 375
Left = 240
TabIndex = 3
Top = 720
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public rcmd0, rcmd1, rcmd2, rcmd3, rcmd4, rcmd5, rcmd6, rcmd7, rcmd8, rcmd9 As Variant
Private Sub cmdConnect_Click()
Winsock1.RemoteHost = txtServer.Text
Winsock1.Connect
Winsock2.RemoteHost = txtServer.Text
Winsock2.Connect
Winsock3.RemoteHost = txtServer.Text
Winsock3.Connect
Winsock4.RemoteHost = txtServer.Text
Winsock4.Connect
Winsock5.RemoteHost = txtServer.Text
Winsock5.Connect
Winsock6.RemoteHost = txtServer.Text
Winsock6.Connect
Winsock7.RemoteHost = txtServer.Text
Winsock7.Connect
Winsock8.RemoteHost = txtServer.Text
Winsock8.Connect
Winsock9.RemoteHost = txtServer.Text
Winsock9.Connect
Winsock10.RemoteHost = txtServer.Text
Winsock10.Connect
cmdConnect.Enabled = False
cmdMsgBox.Enabled = True
cmdDisconnect.Enabled = True
txtServer.Enabled = True
MsgBox "Connection successful.", vbOKOnly + vbInformation, "Connection Status"
End Sub
Private Sub cmdDisconnect_Click()
If Winsock1.State <> sckClosed Then Winsock1.Close
If Winsock2.State <> sckClosed Then Winsock2.Close
If Winsock3.State <> sckClosed Then Winsock3.Close
If Winsock4.State <> sckClosed Then Winsock4.Close
If Winsock5.State <> sckClosed Then Winsock5.Close
If Winsock6.State <> sckClosed Then Winsock6.Close
If Winsock7.State <> sckClosed Then Winsock7.Close
If Winsock8.State <> sckClosed Then Winsock8.Close
If Winsock9.State <> sckClosed Then Winsock9.Close
If Winsock10.State <> sckClosed Then Winsock10.Close
cmdConnect.Enabled = True
cmdDisconnect.Enabled = False
cmdMsgBox.Enabled = False
MsgBox "Disconnection successful.", vbOKOnly + vbInformation, "Connection Status"
End Sub
Private Sub cmdMsgBox_Click()
frmMsgBox.Visible = True
Form1.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Winsock1.State <> sckClosed Then Winsock1.Close
If Winsock2.State <> sckClosed Then Winsock2.Close
If Winsock3.State <> sckClosed Then Winsock3.Close
If Winsock4.State <> sckClosed Then Winsock4.Close
If Winsock5.State <> sckClosed Then Winsock5.Close
If Winsock6.State <> sckClosed Then Winsock6.Close
If Winsock7.State <> sckClosed Then Winsock7.Close
If Winsock8.State <> sckClosed Then Winsock8.Close
If Winsock9.State <> sckClosed Then Winsock9.Close
If Winsock10.State <> sckClosed Then Winsock10.Close
Unload Me
End Sub
frmMsgBox.frm:
VERSION 5.00
Begin VB.Form frmMsgBox
BorderStyle = 3 'Fixed Dialog
Caption = "Choose Message Options"
ClientHeight = 3615
ClientLeft = 2760
ClientTop = 3750
ClientWidth = 6030
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3615
ScaleWidth = 6030
ShowInTaskbar = 0 'False
Begin VB.CheckBox chkSysModal
Caption = "Urgent"
Enabled = 0 'False
Height = 495
Left = 4440
TabIndex = 17
Top = 1920
Width = 1335
End
Begin VB.OptionButton optMsgIcon
Caption = "Exclamation"
Enabled = 0 'False
Height = 375
Left = 2520
TabIndex = 15
Top = 2880
Width = 1215
End
Begin VB.OptionButton optMsgIcon3
Caption = "Critical"
Enabled = 0 'False
Height = 495
Left = 2520
TabIndex = 14
Top = 2400
Width = 855
End
Begin VB.OptionButton optMsgIcon2
Caption = "Question"
Enabled = 0 'False
Height = 375
Left = 2520
TabIndex = 13
Top = 2040
Width = 975
End
Begin VB.OptionButton optMsgIcon1
Caption = "Information"
Enabled = 0 'False
Height = 375
Left = 2520
TabIndex = 11
Top = 1560
Width = 1215
End
Begin VB.OptionButton optMsgType2
Caption = "OK only"
Height = 495
Left = 240
TabIndex = 7
Top = 1800
Width = 1575
End
Begin VB.OptionButton optMsgType1
Caption = "Abort, Retry, Ignore"
Height = 255
Left = 240
TabIndex = 6
Top = 1560
Width = 1695
End
Begin VB.TextBox txtMessage
Height = 375
Left = 1080
TabIndex = 5
Top = 720
Width = 3255
End
Begin VB.TextBox txtTitle
Height = 375
Left = 1080
TabIndex = 2
Top = 240
Width = 3255
End
Begin VB.CommandButton CancelButton
Caption = "Cancel"
Height = 375
Left = 4680
TabIndex = 1
Top = 600
Width = 1215
End
Begin VB.CommandButton OKButton
Caption = "OK"
Height = 375
Left = 4680
TabIndex = 0
Top = 120
Width = 1215
End
Begin VB.Frame Frame1
Caption = "MsgBox Style"
Height = 2175
Left = 120
TabIndex = 8
Top = 1320
Width = 2055
Begin VB.OptionButton optMsgType5
Caption = "Retry, Cancel"
Height = 255
Left = 120
TabIndex = 12
Top = 1800
Width = 1695
End
Begin VB.OptionButton optMsgType4
Caption = "Yes, No"
Height = 375
Left = 120
TabIndex = 10
Top = 1320
Width = 975
End
Begin VB.OptionButton optMsgType3
Caption = "OK, Cancel"
Height = 375
Left = 120
TabIndex = 9
Top = 960
Width = 1215
End
End
Begin VB.Frame Frame2
Caption = "MsgBox Icon"
Height = 2055
Left = 2400
TabIndex = 16
Top = 1320
Width = 1575
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "&Message:"
Height = 255
Left = 120
TabIndex = 4
Top = 720
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "&Title:"
Height = 255
Left = 360
TabIndex = 3
Top = 360
Width = 855
End
End
Attribute VB_Name = "frmMsgBox"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim checked As Integer
Public rcmd20, rcmd21, rcmd22, rcmd23, rcmd24, rcmd25, rcmd26, rcmd27, rcmd28, rcmd29 As Variant
Private Sub CancelButton_Click()
frmMsgBox.Visible = False
End Sub
Private Sub chkSysModal_Click()
If checked = 0 Then
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
optMsgIcon.Enabled = False
optMsgIcon1.Enabled = False
optMsgIcon2.Enabled = False
optMsgIcon3.Enabled = False
rcmd21 = rcmd21 + vbSystemModal
checked = 1
Else
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
optMsgIcon.Enabled = False
optMsgIcon1.Enabled = False
optMsgIcon2.Enabled = False
optMsgIcon3.Enabled = False
rcmd21 = rcmd21 - vbSystemModal
End If
End Sub
Private Sub Form_Load()
checked = 0
End Sub
Private Sub OKButton_Click()
rcmd20 = txtMessage.Text
rcmd22 = txtTitle.Text
Form1.rcmd0 = rcmd20
Form1.rcmd1 = rcmd21
Form1.rcmd2 = rcmd22
Form1.Winsock2.SendData Form1.rcmd0
Form1.Winsock3.SendData Form1.rcmd1
Form1.Winsock4.SendData Form1.rcmd2
Form1.Winsock1.SendData "Message"
frmMsgBox.Visible = False
Form1.Enabled = True
End Sub
Private Sub optMsgIcon_Click()
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
chkSysModal.Enabled = True
rcmd21 = rcmd21 + vbExclamation
End Sub
Private Sub optMsgIcon1_Click()
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
chkSysModal.Enabled = True
rcmd21 = rcmd21 + vbInformation
End Sub
Private Sub optMsgIcon2_Click()
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
chkSysModal.Enabled = True
rcmd21 = rcmd21 + vbQuestion
End Sub
Private Sub optMsgIcon3_Click()
optMsgType1.Enabled = False
optMsgType2.Enabled = False
optMsgType3.Enabled = False
optMsgType4.Enabled = False
optMsgType5.Enabled = False
chkSysModal.Enabled = True
rcmd21 = rcmd21 + vbCritical
End Sub
Private Sub optMsgType1_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbAbortRetryIgnore
End Sub
Private Sub optMsgType2_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbOKOnly
End Sub
Private Sub optMsgType3_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbAbortRetryIgnore
End Sub
Private Sub optMsgType4_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbYesNo
End Sub
Private Sub optMsgType5_Click()
optMsgIcon.Enabled = True
optMsgIcon1.Enabled = True
optMsgIcon2.Enabled = True
optMsgIcon3.Enabled = True
rcmd21 = vbRetryCancel
End Sub
When I send the Message data from client to server, apparently port 1002 gets through, but none of the others do, as I get a blank message box which is not system modal, whatever I put in.
Why?
Please help,
Crystalinity
P.S. Could anyone tell me how to differentiate between arguments at the server from a single string, even if you don't know how long the arguments will be? This would help to make the program one hell of a lot shorter.