Results 1 to 3 of 3

Thread: Winsock is not a socket? Now i'm confused!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    2

    Question Winsock is not a socket? Now i'm confused!

    Ok, I have visual Studio 6 Enterprise Edition, I have service pack 6 and sp6 runtimes, my OS is XP Pro sp2. I've posted in several forums, tried the programming rooms at yahoo... I don't seem to be getting anywhere.

    Here's my problem, I made a client - server app, it's not a rat but just a simple one way text messenger. Cool lookin progress bars an such, most of the code is graphical in nature, alot of wait states for the fakie progress bar. Aside from that my connection routines are simple, with status shown on labels.

    The code compiles fine, but when I try to run it, i get two errors, (one obviously because of the other)

    Error1 (40006) Wrong protocol or connection state for the requested transaction or request.

    Error2 (10038) (The descriptor is not a socket) in Procedure Ws1_ConnectionRequest of form frmServer.


    So far in the last 2 days I have (besides not getting any sleep) Tried unregistering and reinstalling MSWINSCK.OCX, doing the same with an earlier version of the control(can't find a newer one), completely uninstalling Visual Studio and all related componts and then reinstalling, I've tried with and without the service pack and, I've tried it with no other connections active on my machine and on 7 different ports which are all listed as unreserved/unused ports.

    The listen state for the winsock shows on netstat however, but if i try to SendData it gives the errors.

    I don't want to have to use CSocket exclusively, and all my projects are pretty much stalled without Winsock.

    I'm sure my code is good but I'm puttin it here anyway just in case, any help or comments at all would be greatly appreciated. Help me guys...
    ... before I lose my marbles completely, lol!

    SERVER
    VB Code:
    1. Private Sub Form_Load()
    2. '---------------------------------------------------------------------------------------
    3. 'CODE COMMENT: Starts the listen timer
    4. '---------------------------------------------------------------------------------------
    5.     Timer1.Enabled = True
    6. End Sub
    7. Private Sub Timer1_Timer()
    8. '---------------------------------------------------------------------------------------
    9. 'CODE COMMENT: Listens on port 1234, sends status to user, stops the listen timer.
    10. '---------------------------------------------------------------------------------------
    11.     Ws1.Close
    12.     Ws1.Listen
    13. If Ws1.State = sckListening Then
    14.     Call MsgBox("The server is listening on the designated port. (1234)", vbInformation, "Page Admin Server 2.0")
    15. If Ws1.State <> sckListening Then
    16.     Call MsgBox("The server has failed to connect on Port 1234!", vbCritical, "Page Admin Server 2.0")
    17. End If
    18. End If
    19.     Timer1.Enabled = False
    20. End Sub
    21. Private Sub Ws1_ConnectionRequest(ByVal requestID As Long)
    22. '---------------------------------------------------------------------------------------
    23. 'CODE COMMENT: Accepts Incoming connections.
    24. '---------------------------------------------------------------------------------------
    25.    On Error GoTo Ws1_ConnectionRequest_Error
    26.     Ws1.Close
    27.     Ws1.Accept reqestID
    28.    On Error GoTo 0
    29.    Exit Sub
    30. Ws1_ConnectionRequest_Error:
    31.     MsgBox "Error1 " & Err.Number & " (" & Err.Description & ") in procedure Ws1_ConnectionRequest of Form frmServer"
    32. End Sub
    33. Private Sub Ws1_DataArrival(ByVal bytesTotal As Long)
    34. '-------------------------------------------------------------------------------------------------------------------------------
    35. 'CODE COMMENT: Receives incoming data, if data matches parameters it sends a return. Otherwise it starts the listen timer again.
    36. '-------------------------------------------------------------------------------------------------------------------------------
    37.  
    38.     Dim RData As String
    39.    On Error GoTo Ws1_DataArrival_Error
    40.     Ws1.GetData (RData)
    41. If RData = "confirmrequest" And Ws1.State = sckConnected Then
    42.     Ws1.SendData (confirmed)
    43. Else
    44.     Timer1.Enabled = True
    45. End If
    46.    On Error GoTo 0
    47.    Exit Sub
    48. Ws1_DataArrival_Error:
    49.     MsgBox "Error2 " & Err.Number & " (" & Err.Description & ") in procedure Ws1_DataArrival of Form frmServer"
    50. End Sub


    CLIENT
    VB Code:
    1. Dim errorint As Integer
    2. Dim prog1 As Integer
    3. Dim waitstate As Integer
    4. Dim waitstate2 As Integer
    5. Private Sub exitButton_Click()
    6.     End
    7. End Sub
    8. Private Sub Form_Load()
    9.     errorint = 0
    10.     prog1 = 0
    11.     waitstate = 0
    12.     Timer2.Enabled = False
    13. End Sub
    14.  
    15. Private Sub Timer1_Timer()
    16. If prog1 = 990 Then
    17.     Timer1.Enabled = False
    18.     Timer2.Enabled = True
    19. Else
    20.     PBar.Value = prog1
    21.     prog1 = prog1 + 10
    22. End If
    23. End Sub
    24. Private Sub Timer2_Timer()
    25. If errorint = 20 Then
    26.     Call MsgBox("Unable to create an active connection within Pager, this is not due to the admin server being offline. Please report this error to the administrator at [email][email protected][/email]", vbCritical, "Failed...")
    27. End
    28. End If
    29. If waitstate = 5 Then
    30.     PBar.Value = 1000
    31.     Ws1.Close
    32.     Ws1.RemoteHost = "127.0.0.1"
    33.     Ws1.Connect
    34. SendingData:
    35. If Ws1.State <> sckBadState And Ws1.State <> sckWrongProtocol Then
    36.     Dim DeltaData As String
    37.     DeltaData = confirmrequest
    38.     Ws1.SendData DeltaData
    39. Else
    40.     lbl1.Caption = "Retrying"
    41.     Ws1.Close
    42.     Ws1.Connect
    43.     GoTo SendingData
    44.     errorint = errorint + 1
    45. End If
    46. If waitstate = 5 Then Timer2.Enabled = False
    47. Else
    48. waitstate = waitstate + 1
    49. End If
    50. End Sub
    51. Private Sub Ws1_DataArrival(ByVal bytesTotal As Long)
    52.    On Error GoTo Ws1_DataArrival_Error
    53.     RData = confirmation
    54.     Ws1.GetData RData
    55. If confirmation = "confirmed" Then
    56.     lbl1.Caption = "Connection Established"
    57.     titlelbl.Caption = "Success!"
    58.     Timer3.Enabled = True
    59. End If
    60.    On Error GoTo 0
    61.    Exit Sub
    62. Ws1_DataArrival_Error:
    63.     lbl1.Caption = "The admin appears to be offline."
    64.     titlelbl.Caption = "Failed..."
    65.     exitButton.Visible = True
    66. End Sub
    67. Private Sub Timer3_Timer()
    68.     waitstate2 = 0
    69. If waitstate2 = 2 Then
    70.     lbl1.Caption = "Authenticating..."
    71. End If
    72. If waitstate2 = 4 Then
    73.     lbl1.Caption = "Confirmed... Building Interface..."
    74. End If
    75. If waitstate2 = 5 Then
    76.     lbl1.Caption = "Loading..."
    77. End If
    78.     prog1 = prog1 + 300
    79.     PBar.Value = prog1
    80. If prog = 2000 Then
    81.     frmPage.Show
    82.     frmSplash.Hide
    83. End If
    84. End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Winsock is not a socket? Now i'm confused!

    Post me the actual applications,

    Error1 (40006) Wrong protocol or connection state for the requested transaction or request.
    that error means that you are not connected and you are trying to send data.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    2

    Re: Winsock is not a socket? Now i'm confused!

    Thanks for answering Pino, I can't post the compiled app becuase then it won't work for any one, I don't believe it is the code, I think it is an error in my winsock, but I've repalced it several times. I have the source here for you, full project files. And I know what that error means, I only included it because it was the initial error, the true error is the not a socket eror but it was only returned after adding an error handler to report it. The connection error is a byproduct of the socket error.
    Attached Files Attached Files

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