Results 1 to 3 of 3

Thread: System.net.Sockets.Socket bind problem

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    38

    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:
    1. lSocket.Bind(New IPEndPoint(Dns.GetHostByName(LocalHostName).AddressList(0).Any, LocalPort))
    2.       lSocket.Listen(5)
    3.       result = lSocket.BeginAccept(AddressOf ConnectionRequest, lSocket)
    4.       lSocket = result.AsyncState

    then, i close the socket and do something like:
    VB Code:
    1. lSocket.Close()
    2.     lSocket = Nothing
    3.     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?

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    38

    Re: System.net.Sockets.Socket bind problem

    No ideia why? =(

  3. #3
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    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!
    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width