TCP/IP Connections

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • it.dotnet.vb

    TCP/IP Connections

    Hi all,

    i'm trying to make an application that have a server component that open a
    socket waiting for client connection. I'm having this problem: when the
    execution reach the statement that put the server socket in listening (using
    synchronous or asyncronous communication mode), it stops and wait until
    happens a connection request.

    This way is different from the old winsock that i used in vb6, because with
    the old vb control i could put the object in listen state without stop the
    application execution. When a client try to connect, the ConnectionReque st
    event was raised.

    There's a way to manage internet/intranet connection through new VB.NET
    classes having the same result then with the old winsock component?

    thanks....

    TheVell


  • Scott H

    #2
    Re: TCP/IP Connections


    I had a similar experience coming from VB6. As far as I can see the
    best way to do this is when you want to start the server listening,
    put the required code in a seperate sub, followed by code to handle
    the connection, interpret any commands and send data back to the user
    all in that one sub or split up maybe to make it more readable and
    structured. Once you've done that, when you want to start it all
    going, create a new thread and start that, the rest of your program
    will continue to run and the server will take care of itself.

    If like me you hadn't done multithreading before, don't panic, its
    really quite easy...

    Dim th as new system.threadin g.thread (AddressOf MyThread)
    th.Start
    ...
    ...

    Private Sub Mythread
    your server stuff goes here
    End sub

    To make it a bit more like Old Winsock, you can Raise an event in the
    thread just after accepting the connection, so your program can
    respond to that much like the ConnectRequest event

    Hope that Helps

    Scott




    On Fri, 4 Jun 2004 20:08:14 +0200, "it.dotnet. vb" <gvellusi@tin.i t>
    wrote:
    [color=blue]
    >Hi all,
    >
    >i'm trying to make an application that have a server component that open a
    >socket waiting for client connection. I'm having this problem: when the
    >execution reach the statement that put the server socket in listening (using
    >synchronous or asyncronous communication mode), it stops and wait until
    >happens a connection request.
    >
    >This way is different from the old winsock that i used in vb6, because with
    >the old vb control i could put the object in listen state without stop the
    >application execution. When a client try to connect, the ConnectionReque st
    >event was raised.
    >
    >There's a way to manage internet/intranet connection through new VB.NET
    >classes having the same result then with the old winsock component?
    >
    >thanks....
    >
    >TheVell
    >
    >[/color]

    Comment

    • TheVell

      #3
      Re: TCP/IP Connections

      Hi Scott,

      you center the problem and solve it... :-)
      Now i have to understand the world of threads.....

      thanks a lot

      TheVell


      Comment

      • Scott H

        #4
        Re: TCP/IP Connections


        Glad I could help.
        Threads are not that complicated, at least now with Dot Net, a Thread
        is just a regular Sub that runs independant of your main program. Just
        one catch though, you can't pass parameters like you can regular
        subs... But there's many way around that, check out many of the
        examples on the web, thats I how learned how to use them.

        Scott


        On Sun, 6 Jun 2004 12:02:27 +0200, "TheVell" <gvellusi@tin.i t> wrote:[color=blue]
        >Hi Scott,
        >
        >you center the problem and solve it... :-)
        >Now i have to understand the world of threads.....
        >
        >thanks a lot
        >
        >TheVell
        >[/color]

        Comment

        Working...