CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 1999
    Posts
    2

    Winsock .Connect & .Close Problem



    While connecting and closing is a no problem, but once i .close and want to reconnect ( .connect ) again, somehow the other side wouldnt want to respond to my .connect


    Do i need like to initialize something or close some other function before reconnecting ( .connect ) again?


    Client connects to server. No problem, client .close from server, no problem also. But when i want the client to .connect again to the server, no response.


    Please help...

  2. #2
    Join Date
    Feb 1999
    Posts
    12

    Re: Winsock .Connect & .Close Problem



    This is the way that I solved this problem..


    Whenever your application have to provide re-establish connection, you have to

    1. create a form with winsock control (example name : frmsocket, and winsock)

    2. Declare global variable as control (example : mysocket)

    3. when you want to open connection

    3.1 set mysocket = new frmsocket

    3.2 openconnection by mysocket.winsock.open

    4. when you want to close connection, you have also unload the form.

    4.1 mysocket.winsock.close

    4.2 mysocket.unload

    4.3 set mysocket = nothings (release the resource for this objects)


    because of everytime when the winsock has been opened, the system will generate the unique/unreuseable socket handlenumber automatically, so you have to always create a new winsock at runtime.


    sorry for my weak english.

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

Featured