TCP/IP Connections

I

it.dotnet.vb

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 ConnectionRequest
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
 
S

Scott H

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.threading.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
 
T

TheVell

Hi Scott,

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

thanks a lot

TheVell
 
S

Scott H

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top