"Connection pending" all the time
"Connection pending" all the time
"Connection pending" all the time
"Connection pending" all the time
"Connection pending" all the time
"Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time
"Connection pending" all the time "Connection pending" all the time
"Connection pending" all the time
Go Back  Xtreme Visual Basic Talk > > > "Connection pending" all the time


Reply
 
Thread Tools Display Modes
  #1  
Old 03-16-2005, 12:42 AM
Maria76 Maria76 is offline
Centurion
 
Join Date: Feb 2004
Posts: 149
Default "Connection pending" all the time


Hello,
When disconnecting server, I am closing the active winsock connections.
When I open it again I can sometimes have asd the state "connection pending", in the client side it shows "connected".
What is this connection pending? why it is not Listening?
Before when I did not close winsock connections i did not have this. but i experienced that sometimes the connections was still there and loaded and hence a run time error of object already loaded could appear.
Reply With Quote
  #2  
Old 03-16-2005, 09:59 PM
calvn84 calvn84 is offline
Regular
 
Join Date: Mar 2003
Location: Idaho, USA
Posts: 92
Default

What code are you using to "close" the socket? Do you put socket(number).listen after you close it?
__________________
-Calvn84
Reply With Quote
  #3  
Old 03-16-2005, 11:05 PM
Maria76 Maria76 is offline
Centurion
 
Join Date: Feb 2004
Posts: 149
Default

Hello!
This is what I use to close the socket:

For all those sockets that are loaded:

Winsock(x).Close


and then the main one:

Winsock(0).Close

and this is the Close function:

Private Sub Winsock_Close(Index As Integer)


Winsock(Index).Close
Unload Winsock(Index)

ConnArray(Index) = "free"

iSockets = iSockets - 1
lblConnections.Caption = "Active Connection(s) :" & iSockets

End Sub


And then when I start the server I start to listen:

Winsock(0).LocalPort = 1009
Winsock(0).Listen



This can sometimes result in that the state will stay in "Connection Pending" for 5-10 minutes....
Reply With Quote
  #4  
Old 03-16-2005, 11:33 PM
calvn84 calvn84 is offline
Regular
 
Join Date: Mar 2003
Location: Idaho, USA
Posts: 92
Default

If you change:
Code:
Unload Winsock(Index)

to:
Code:
Winsock(index).Listen

you'll most likely get the results you're looking for.

If you don't, you're labeling a socket "free" when in actuallity it doesn't exist because you unloaded it.
__________________
-Calvn84
Reply With Quote
  #5  
Old 03-17-2005, 12:56 AM
Maria76 Maria76 is offline
Centurion
 
Join Date: Feb 2004
Posts: 149
Default

Hmm , I don't really understand
Im having a separate Array ConnArray() to track the "loaded" and "free" sockets. I guess this is not the best way to do it but when loading the form im assign an array of 50 (50 connections possible) the value "free"

for x = 1 to 50
ConnArray(x)="free"
Next

Then in the form load event I start to listen:

Winsock(0).Listen

and then when a connection requst is coming i assign a socket number that corresponds to free in the ConnArray:

For x = 1 To 50
If ConnArray(x) = "free" Then

Load Winsock(x)
ConnArray(x) = "loaded"

Winsock(x).LocalPort = 1009
Winsock(x).Accept requestID
Exit for
Next

... and then when it is closed i unload that socket and assign the corresponding ConnArray elemnt the string "free" again..

SO when i close the server i want to close the listening port
Winsock(0).Close as well as the sockets that i have opened. I knwo that I have opened the sockets that have the "loaded" string in the corresponding ConnArray element number:

For x = 1 To 50
If ConnArray(x) = "loaded" Then

Winsock(x).Close
End If
Next


Winsock(0).Close ' and then the listening one.


And here is the code for CLOSE:

Private Sub Winsock_Close(Index As Integer)



Winsock(Index).Close
Unload Winsock(Index)

ConnArray(Index) = "free"

iSockets = iSockets - 1
lblConnections.Caption = "Active Connection(s) :" & iSockets

End Sub


It seems that I dont understand something fundamental here since I dont know why I should put the socket to listen and not unload at this stage!!

In the NETSTAT i have so many connections to this one port, somehow its not doing it correctly !?!
Reply With Quote
  #6  
Old 03-17-2005, 08:07 AM
b0b b0b is offline
Contributor
 
Join Date: Jul 2003
Posts: 741
Default

The Winsock_Close event will not fire due to a local socket close.

Quote:
For x = 1 To 50
If ConnArray(x) = "loaded" Then

Winsock(x).Close
End If
Next
Doing this will not cause the Winsock_Close to fire and so you are not unloading the sockets like you intended.

The "connection pending" state is strange, but you have to take into acount that sockets take time to close and if you are not unloading them they will have a different state to the one you expected.

I suggest you read the tutorials here on winsock control arrays and reciving mulitple connections if you haven't already.
http://www.winsockvb.com/index.php?cat_id=3
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
"Connection pending" all the time
"Connection pending" all the time
"Connection pending" all the time "Connection pending" all the time
"Connection pending" all the time
"Connection pending" all the time
"Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time "Connection pending" all the time
"Connection pending" all the time
"Connection pending" all the time
 
"Connection pending" all the time
"Connection pending" all the time
 
-->