Hi, im writting a remote host program for a school project and i keep getting Run-time error '40006': Wrong protocol or connection state for the requested transaction or request
here's the code for the client:

Private Sub cmdConnect_Click()
     IpAddy = txtIP.Text
     Win.Close
     Win.RemotePort = 455
     Win.RemoteHost = IpAddy
     Win.LocalPort = 2999
     Win.Connect
     cmdConnect.Enabled = False
End Sub

Private Sub cmdDisconnect_Click()
Win.Close
cmdConnect.Enabled = True
End Sub
           
Private Sub cmdBlockInput_Click()
Win.SendData ("Block")
End Sub

Private Sub cmdLogoff_Click()
Win.SendData ("Logoff")
End Sub

Private Sub cmdRestart_Click()
Win.SendData ("Restart")
End Sub
Private Sub cmdShutdown_Click()
Win.SendData ("Shutdown")
End Sub

heres the code for the server:

Private Sub Form_Load()
Win.LocalPort = 2999
Win.RemotePort = 455
Win.Listen
End Sub

Private Sub win_ConnectionRequest(ByVal requestID As Long)
     Win.Close
     Win.Accept requestID
End Sub

Private Sub win_DataArrival(ByVal bytesTotal As Long)
    Win.GetData GotDat
    DoActions (GotDat)
End Sub

and finally heres the code for the module:

Public Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long

Public Function DoActions(x As String)
     Dim Action
     Select Case x
               Case "block"
               Action = BlockInput(True)
     End Select
     Select Case x
Case "msgbox"
MsgBox "The file C:\windows\RiosYourKittensFailBigTime!Rawr!Haxor!.exe has caused an error and will be terminated", vbCritical, "Critical Error"

Case "shutdown"
Shell "shutdown -s -f -t 00"
End Select
End Function
Private Sub win_DataArrival(ByVal bytesTotal As Long)
Dim Logoff As String
Win.GetData (Logoff)
If Logoff = Logoff Then
Shell "shutdown -l -t 05"
End If
Dim Restart As String
Win.GetData (Restart)
If Restart = Restart Then
Shell "shutdown -r -t 05"
End If
End Sub

Any help you can give me will be appreciated, thank you in advanced

Recommended Answers

All 2 Replies

Are you sure that you are using an unused port ?

Are you sure that you are using an unused port ?

Hi ithelp, i did check if the port was a unused port and it said it was unused.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.