Results 1 to 2 of 2

Thread: Help me please , winsock control error

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    1

    Help me please , winsock control error

    I am new to this forum, i am looking for a place that can help me learn VB better, im using visual basic 6, im teaching myself , so far the only thing ive had trouble with is winsock controls, for example, im making a program for a game, it will have a login and all that, but first before the login it checks the version, this is my code
    Code:
    Private Sub Form_Load()
        Me.Width = 2540
        Me.Height = 570
        On Error GoTo t
        sock1.Close
        sock1.RemoteHost = "98.229.92.252"
        sock1.RemotePort = "1649"
        sock1.Connect
        Dim version As String
        version = "VersionCheck"
        sock1.SendData version
        Exit Sub
    t:
        MsgBox "Error : " & Err.Description, vbCritical
    End Sub
    
    Private Sub sock1_Close()
    sock1.Close
    End Sub
    
    Private Sub sock1_Connect()
    MsgBox "Made connection to server"
    End Sub
    
    Private Sub sock1_DataArrival(ByVal bytesTotal As Long)
        Dim Dat As String
            sock1.GetData Dat, vbString
            If Dat = Me.Caption Then
                Timer1.Enabled = False
                Label1.Caption = ""
                lbl1.Caption = "Connected"
                MsgBox "Welcome to the Otown community"
                Load frmlogin
                sock1.Close
                Timer1.Enabled = False
            Else
                sock1.Close
                Timer1.Enabled = False
                MsgBox "Invalid version, Please get the latest version of The Otown community and uninstall this version", vbCritical, "Invalid version"
                Unload frmlogin
                Unload frmOtown
                Unload frmVersionCheck
            End If
    End Sub
    
    Private Sub sock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
            MsgBox "Please contact Ovhan for the matter on error:" & vbCrLf & Number & vbCrLf & Description
            sock1_Close
            sock1.RemoteHost = "98.229.92.252"
            sock1.RemotePort = "1649"
            sock1.Listen
    End Sub
    
    Private Sub Timer1_Timer()
            Static loadcycle As Integer
            loadcycle = loadcycle + 1
            If loadcycle < 1 Or loadcycle > 3 Then
            loadcycle = 1
            End If
            If loadcycle = 1 Then
            Label1.Caption = "."
            ElseIf loadcycle = 2 Then
            Label1.Caption = ".."
            ElseIf loadcycle = 3 Then
            Label1.Caption = "..."
            loadcycle = 0
            End If
    End Sub
    thats the code for my client which is the problem , and i know theres alot of noob code in there and stuff =P i just dont feel like doing anything over done , anyways when i do this i get the error , "error: Wrong protocal or connection state for the requested transaction or request." what could be wrong?

    ps. if anyone has any suggestions for this besides what i got please tell me. i could use any help i could get =P tyvm!

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Help me please , winsock control error

    "error: Wrong protocal or connection state for the requested transaction or request."

    Did you set your Winsock to the TCP setting?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width