|
-
Jun 17th, 2005, 12:39 PM
#1
Thread Starter
New Member
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:
Private Sub Form_Load()
'---------------------------------------------------------------------------------------
'CODE COMMENT: Starts the listen timer
'---------------------------------------------------------------------------------------
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
'---------------------------------------------------------------------------------------
'CODE COMMENT: Listens on port 1234, sends status to user, stops the listen timer.
'---------------------------------------------------------------------------------------
Ws1.Close
Ws1.Listen
If Ws1.State = sckListening Then
Call MsgBox("The server is listening on the designated port. (1234)", vbInformation, "Page Admin Server 2.0")
If Ws1.State <> sckListening Then
Call MsgBox("The server has failed to connect on Port 1234!", vbCritical, "Page Admin Server 2.0")
End If
End If
Timer1.Enabled = False
End Sub
Private Sub Ws1_ConnectionRequest(ByVal requestID As Long)
'---------------------------------------------------------------------------------------
'CODE COMMENT: Accepts Incoming connections.
'---------------------------------------------------------------------------------------
On Error GoTo Ws1_ConnectionRequest_Error
Ws1.Close
Ws1.Accept reqestID
On Error GoTo 0
Exit Sub
Ws1_ConnectionRequest_Error:
MsgBox "Error1 " & Err.Number & " (" & Err.Description & ") in procedure Ws1_ConnectionRequest of Form frmServer"
End Sub
Private Sub Ws1_DataArrival(ByVal bytesTotal As Long)
'-------------------------------------------------------------------------------------------------------------------------------
'CODE COMMENT: Receives incoming data, if data matches parameters it sends a return. Otherwise it starts the listen timer again.
'-------------------------------------------------------------------------------------------------------------------------------
Dim RData As String
On Error GoTo Ws1_DataArrival_Error
Ws1.GetData (RData)
If RData = "confirmrequest" And Ws1.State = sckConnected Then
Ws1.SendData (confirmed)
Else
Timer1.Enabled = True
End If
On Error GoTo 0
Exit Sub
Ws1_DataArrival_Error:
MsgBox "Error2 " & Err.Number & " (" & Err.Description & ") in procedure Ws1_DataArrival of Form frmServer"
End Sub
CLIENT
VB Code:
Dim errorint As Integer
Dim prog1 As Integer
Dim waitstate As Integer
Dim waitstate2 As Integer
Private Sub exitButton_Click()
End
End Sub
Private Sub Form_Load()
errorint = 0
prog1 = 0
waitstate = 0
Timer2.Enabled = False
End Sub
Private Sub Timer1_Timer()
If prog1 = 990 Then
Timer1.Enabled = False
Timer2.Enabled = True
Else
PBar.Value = prog1
prog1 = prog1 + 10
End If
End Sub
Private Sub Timer2_Timer()
If errorint = 20 Then
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...")
End
End If
If waitstate = 5 Then
PBar.Value = 1000
Ws1.Close
Ws1.RemoteHost = "127.0.0.1"
Ws1.Connect
SendingData:
If Ws1.State <> sckBadState And Ws1.State <> sckWrongProtocol Then
Dim DeltaData As String
DeltaData = confirmrequest
Ws1.SendData DeltaData
Else
lbl1.Caption = "Retrying"
Ws1.Close
Ws1.Connect
GoTo SendingData
errorint = errorint + 1
End If
If waitstate = 5 Then Timer2.Enabled = False
Else
waitstate = waitstate + 1
End If
End Sub
Private Sub Ws1_DataArrival(ByVal bytesTotal As Long)
On Error GoTo Ws1_DataArrival_Error
RData = confirmation
Ws1.GetData RData
If confirmation = "confirmed" Then
lbl1.Caption = "Connection Established"
titlelbl.Caption = "Success!"
Timer3.Enabled = True
End If
On Error GoTo 0
Exit Sub
Ws1_DataArrival_Error:
lbl1.Caption = "The admin appears to be offline."
titlelbl.Caption = "Failed..."
exitButton.Visible = True
End Sub
Private Sub Timer3_Timer()
waitstate2 = 0
If waitstate2 = 2 Then
lbl1.Caption = "Authenticating..."
End If
If waitstate2 = 4 Then
lbl1.Caption = "Confirmed... Building Interface..."
End If
If waitstate2 = 5 Then
lbl1.Caption = "Loading..."
End If
prog1 = prog1 + 300
PBar.Value = prog1
If prog = 2000 Then
frmPage.Show
frmSplash.Hide
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|