|
-
Dec 21st, 2006, 08:44 PM
#1
Thread Starter
Member
System.net.Sockets.Socket bind problem
Well, this is the code. lSocket is a Socket. On the first time i bind the endpoint and te port. And it works perfectly!
VB Code:
lSocket.Bind(New IPEndPoint(Dns.GetHostByName(LocalHostName).AddressList(0).Any, LocalPort))
lSocket.Listen(5)
result = lSocket.BeginAccept(AddressOf ConnectionRequest, lSocket)
lSocket = result.AsyncState
then, i close the socket and do something like:
VB Code:
lSocket.Close()
lSocket = Nothing
lSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
And when i bind the socket again, it returns the error:
"Normaly, it's only possible to use once each socket adress".
Dunno why, the bind still there! if i change the port, it works with no problem, but i want the same door. But i can close the socket, destroy it, create it again and bind it.
Any suggestion?
-
Dec 23rd, 2006, 04:49 PM
#2
Thread Starter
Member
Re: System.net.Sockets.Socket bind problem
-
Dec 23rd, 2006, 08:54 PM
#3
Re: System.net.Sockets.Socket bind problem
When I use sockets in .net I use this control:
http://www.codeproject.com/useritems/winsock2005.asp
it works the same as the VB6 winsock. Very simple!
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
|