"Address in use" while REconnecting
"Address in use" while REconnecting
"Address in use" while REconnecting
"Address in use" while REconnecting
"Address in use" while REconnecting
"Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting
"Address in use" while REconnecting "Address in use" while REconnecting
"Address in use" while REconnecting
Go Back  Xtreme Visual Basic Talk > > > "Address in use" while REconnecting


Reply
 
Thread Tools Display Modes
  #1  
Old 02-25-2002, 06:07 AM
ccb
Guest
 
Posts: n/a
Unhappy "Address in use" while REconnecting


when i connect a second time to a server using winsock i get a
"address in use"-error
if i wait some time a reconnection is possible
WHAT the hell might that be??

i reseted the server and closed the connection after connection was closed the first time , so everything looked like before the first connection
Reply With Quote
  #2  
Old 02-25-2002, 06:28 AM
Squirm's Avatar
Squirm"Address in use" while REconnecting Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

You need to use a different LocalPort.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #3  
Old 02-25-2002, 06:48 AM
ChiefRedBull's Avatar
ChiefRedBull"Address in use" while REconnecting ChiefRedBull is offline
ISearchGoogle

Retired Moderator
* Expert *
 
Join Date: May 2001
Location: england
Posts: 6,321
Default

Ports on the lcoal machine are held open for a while after usage, not sure why though.

If yuo open a command prompt and type "netstat -n" without the quotes, you'll see a list of ports, and their states. They vary from ESTABLISHED, to CLOSE_WAIT, and LAST_ACK and others. You will find that most ports will sit on CLOSE_WAIT for a minute or so after closing a connection.
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
Reply With Quote
  #4  
Old 02-25-2002, 08:15 AM
ccb
Guest
 
Posts: n/a
Default

i know examples of simplest chat where u can connect and reconnect as often as u want without time-restriction

and their code "seems" not to differ from my one...

they just close the connection and can immediatly connect to server


HOW is that possible????


PS:
everytime a a client closed connection to a server he himself becomes one(is listening) until new connection by user is wanted
Reply With Quote
  #5  
Old 02-25-2002, 08:26 AM
ccb
Guest
 
Posts: n/a
Default free port

CAN SOMEBODY TELL ME HOW TO RESET THAT PORT
(that i can use it for a connection immediatly and do not have to wait)
??

btw: netstat shows:--> TIME-WAIT for that port (about 1 minute)
Reply With Quote
  #6  
Old 02-25-2002, 08:32 AM
divil's Avatar
divil"Address in use" while REconnecting divil is offline
Funky Monkey

* Expert *
 
Join Date: Nov 2001
Location: England
Posts: 1,289
Default

You can accept any number of connections on a port you are listening on. The listening winsock control doesn't stop listening unless you tell it to.
__________________
MVP, C#
Now you see why evil will always triumph - because good is dumb.
Windows Forms and WPF user interface controls
Reply With Quote
  #7  
Old 02-25-2002, 02:49 PM
ccb
Guest
 
Posts: n/a
Default Solution is SOOO easy

thanks guys for your help...
none of it worked

i got the solution:

everytime i want to connect to a server i just have to set "LocalPort" to "0" ... because if its not a reconnect won´t work a second time...
no clue why

thx anyway


great forum!!!!
Reply With Quote
  #8  
Old 02-25-2002, 02:54 PM
ChiefRedBull's Avatar
ChiefRedBull"Address in use" while REconnecting ChiefRedBull is offline
ISearchGoogle

Retired Moderator
* Expert *
 
Join Date: May 2001
Location: england
Posts: 6,321
Default

As long as you dont tell your server winsock to stop listening there shouldn't be a problem....
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
Reply With Quote
  #9  
Old 02-25-2002, 04:58 PM
Squirm's Avatar
Squirm"Address in use" while REconnecting Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

The reason 0 works as a LocalPort is because it assigns a random port to the sock each time. This is fine for client applications, but for server apps this is often not wanted because the clients wont know which port to connect to. A better approach would be to either prevent the listening sock from closing, or to have the server listen on a port within a given range, so the client apps have at least some idea of where to look.

__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #10  
Old 02-25-2002, 05:14 PM
ChiefRedBull's Avatar
ChiefRedBull"Address in use" while REconnecting ChiefRedBull is offline
ISearchGoogle

Retired Moderator
* Expert *
 
Join Date: May 2001
Location: england
Posts: 6,321
Default

The way i do it is to have two socks, one to listen continually on the same port, and another to accept incoming connections. Because the socks that accept the connections aren't listening, they are assigned a random port by windows, and the original listening sock never loses control over its port.
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
Reply With Quote
  #11  
Old 02-25-2002, 09:10 PM
The IceMan
Guest
 
Posts: n/a
Default netstat ?

Well...The netstat in DOS I knew

but, I would like cery much if someone attachs a sample with the netstat in VB !

Thanx !!
Reply With Quote
  #12  
Old 02-26-2002, 01:33 PM
ChiefRedBull's Avatar
ChiefRedBull"Address in use" while REconnecting ChiefRedBull is offline
ISearchGoogle

Retired Moderator
* Expert *
 
Join Date: May 2001
Location: england
Posts: 6,321
Default

There isn't a netstat in VB... it runs in DOS.

However, you can call it to run from within VB code, using the ShellExecute function.

I think The_Hand posted an example of Shelling the program and waiting for it to end, then collecting the output in the Code Library...
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
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
"Address in use" while REconnecting
"Address in use" while REconnecting
"Address in use" while REconnecting "Address in use" while REconnecting
"Address in use" while REconnecting
"Address in use" while REconnecting
"Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting "Address in use" while REconnecting
"Address in use" while REconnecting
"Address in use" while REconnecting
 
"Address in use" while REconnecting
"Address in use" while REconnecting
 
-->