Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   Communications (http://www.xtremevbtalk.com/communications/)
-   -   Winsock Nightmare : 10053 Connection is aborted due to timeout or other failure (http://www.xtremevbtalk.com/communications/42408-winsock-nightmare-10053-connection-aborted-due-timeout-failure.html)

Cyberax 09-30-2002 09:48 AM

Winsock Nightmare : 10053 Connection is aborted due to timeout or other failure
 
Hi Guys,

Im having a bit of a winsock nightmare,

The purpose of my application is to poll a database for TCP requests then send the information to another computer,the data transfer works 2 way so i am using the same application on both compuers.

Im dont think i know enough about the winsock as i would like to, but to be honest i have been through many pages and sites on the web and found this one the most informative.

OKAY Heres the question:

* * * * * * * * * *

i have added an option in the winsock_error event that outputs the details of the error to screen and whenever i have multiple connections at the same time, i get the following error
"10053 Connection is aborted due to timeout or other failure" also when i get this error it seems to make my application think that the winsock object(which i create at runtime in an array to allow multiple connections) has unloaded as the winsock.count method reports the wrong amount of loaded objects.

* * * * * * * * * *

To be honest though this is more of a bug than a problem as my program works exectly how i want it but the winsock keeps returning that error. which i want to solve before i move on in developing the program anymore.

* * * * * * ** * * * *

I have looked all over the MSDN and TECHNET pages and even scanned this forum and i seem to have exhausted all possible locations for information on the VB Winsock control.

Any help would be Appreciated,

Many Thanks

Ian,

ChiefRedBull 09-30-2002 11:58 AM

I think it would be best if you posted your code... at least the
relevant sections to the error - including the line that causes it.

Cyberax 09-30-2002 04:47 PM

Its a winsovck error
 
this error is not a vb error but gets reported by winsock and the program carries on running, and i have no on error handles.

i can paste all the winsock code but it has not been possible for me to trace where in the program the error occurs as the event fires only when i have an array of winsocks open and if i step through execution then this wont occur as i am firing through the execution at a different rate.

i am just wondering if anyone has had this problem before.

Cyberax 10-01-2002 03:45 AM

The Code !?!
 
I have pasted all the code of which i think is relavent, this is basicly all the vb code for the Listen winsock control.

The error is only reported when i have multiple loaded winsocks, i.e. when 4 connections come in at once.

the problem is though, the program does do everything its supposed to do, it works but this error has me worried as there must be something that i am doing wrong.


Code:
Private Sub Listen_ConnectionRequest(Index As Integer, ByVal requestID As Long) 'Get a new consequtive ID for winsock CtrlID = Listen.UBound + 1 'Load a new winsock to accept incomming Load Listen(CtrlID) 'Initiate a 10 second timeout counter for this control Load TmrTimeout(CtrlID) TmrTimeout(CtrlID).Interval = 10000 TmrTimeout(CtrlID).Enabled = True 'Accept the request with the requestID parameter. Listen(CtrlID).Accept requestID 'Send a connected message to client machine WelcomeMsg = IP_Address & " " & Now Listen(CtrlID).SendData WelcomeMsg DoEvents End Sub Private Sub Listen_DataArrival(Index As Integer, ByVal bytesTotal As Long) 'Accepting data from client . . . . strData = "" Listen(Index).GetData strData 'Validate and insert this data DataRxdOk = False Call LaunchService 'Send back a notification to client If DataRxdOk Then 'Everything was launched fine Listen(Index).SendData "Ok" Else 'Something is wrong Listen(Index).SendData "Error" End If 'Allow winsock to send the delivery response DoEvents 'Close connection Listen(Index).Close DoEvents 'Unload control element + timeout Unload Listen(Index) Unload TmrTimeout(Index) End Sub 'It is this event that the error is reported but the program 'continues execution Private Sub Listen_Error(Index As Integer, 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) Debug.Print Number & " " & Description LstErrors.AddItem ("WS Err(" & Index & ")" & Number & " " & Description) End Sub Private Sub TmrTimeout_Timer(Index As Integer) Dim ErrReason As String If Listen(Index).State = sckConnected Then 'Client isnt sending data ErrReason = "Client Timeout" Listen(Index).SendData "Timeout" Else 'Client has disconnected ErrReason = "Lost Connection : " & TcpState(Listen(Index).State) End If DoEvents 'Close + unload Listen(Index).Close Unload Listen(Index) TmrTimeout(Index).Enabled = False Unload TmrTimeout(Index) End Sub

ChiefRedBull 10-01-2002 04:24 AM

So when you're running the program, if several people try
to join at once, the error fires? Hmm...

You could try implementing a small state machine. Basically,
a variable public to the form with Listen on - each time a
_ConnectionRequest() is received, the first thing you should
do in the sub is check if the variable is flagged. This variable is
used to say whether a connection request is already taking
place. If there's no connection request happening, then proceed
with the current one:
Code:
_ConnectionRequest() If bInProgress Then Exit Sub bInProgress = True ' code bInProgress = False End Sub
That's it really, although it might not be this sub that's causing
the error.. since it could be the Winsock OCX itself, in which case,
adding the above won't make any difference.

If the program conntinues as it's supposed to, then I'd just put
this one down to MS, or perhaps implement some socket API
instead? :)

Cyberax 10-01-2002 05:22 AM

Found The Problem
 
Many Thanks for the reply Chief and your suggestion did solve the winsock problem which meant all errors were handled by my application. Many Thanks . .

I think i may have discovered the problem, if anyone is interested ?

To be honest i think chief knew this was the problem has his previous post solved it.

I outputted all the status information to a text file with the status the object and the index / control array index of the object i also added the time in NN:SS format but as you can see the program fired pretty quickly.

When i tested the program i did it with 5 simaltaneous requests, which were posted by this application but a different executable on a server on my LAN.

Now the problem is that as the connections are coming in so fast it is somehow firing a new event whenever the program hits the doevents that allows my winsock to send a "Connection OK" status back to the Host.

Meaning that the previous winsock is not closing its connection till the end of the program.

I think i have discovered that my current method for dealing with consequtive connections is not the most effecient.

The program is really doing some weird stuff as like i have said the main output result is what i want but when i look at the processes behind it , i shouldnt even work.

I have added the brackets myself just to cut the log into managable chunks.


((
"Load Listen(1) 56:27"
"Load Tmr(1) 56:27"
"Accept 1 56:27"
"rxd data 1 56:27"
"sendok 1 56:27"
"close 1 56:27"
"unload 1 56:27"
))

<<
"Sendwelcome 1 56:27"
"Load Listen(1) 56:27"
"Load Tmr(1) 56:27"
"Accept 1 56:27"
"Sendwelcome 1 56:27"
"rxd data 1 56:27"
"sendok 1 56:27"
>>

((
"Load Listen(2) 56:27"
"Load Tmr(2) 56:27"
"Accept 2 56:27"
"rxd data 2 56:27"
"sendok 2 56:28"
))

<<
"Load Listen(3) 56:28"
"Load Tmr(3) 56:28"
"Accept 3 56:28"
"10053 Connection is aborted due to timeout or other failure 56:28"
"10053 Connection is aborted due to timeout or other failure 56:28"
"rxd data 3 56:28"
"sendok 3 56:28"
>>

((
"Load Listen(4) 56:28"
"Load Tmr(4) 56:28"
"Accept 4 56:28"
"10053 Connection is aborted due to timeout or other failure 56:28"
"10053 Connection is aborted due to timeout or other failure 56:28"
"10053 Connection is aborted due to timeout or other failure 56:28"
"10053 Connection is aborted due to timeout or other failure 56:28"
"rxd data 4 56:28"
"sendok 4 56:28"
"close 4 56:28"
"unload 4 56:28"
))

<<
"Sendwelcome 4 56:28"
"close 3 56:28"
"unload 3 56:28"
"Sendwelcome 4 56:28"
"close 2 56:28"
"unload 2 56:28"
"Sendwelcome 4 56:28"
"close 1 56:28"
"unload 1 56:28"
>>

Cyberax 10-01-2002 07:03 AM

I have found an excellent control array at :

http://www.winsockvb.com/tutorials/array/array1.html

which is a user control created by Will Barden his code is a lot
tidier than mine and his control handles events with style.

anyone using simaltaneous winsock connections i reccomend this to you ....


Many thanks to Chief for his help !?

ChiefRedBull 10-01-2002 09:29 AM

Chief == Will Barden :D

(Mine doesn't do what I suggested to you above, perhaps
I should implement it... when I've got time).

Cyberax 10-01-2002 09:52 AM

May be i can implement it to your code and if you approve i may save you some time !

ChiefRedBull 10-01-2002 10:14 AM

It wouldn't take me long, and I've got a lot of other stuff on right
now (WinsockVB is going through a bit of an overhaul), but thanks
for the offer. :)

truerad 05-16-2016 11:19 AM

The same problem
 
I got the same problem, and i want to learn from this link

winsockvb.com

but this link can not be opened. Is there any other link to go to this page?

Thansk & Regards,


All times are GMT -6. The time now is 04:48 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.