Back to product page

Using wodSSHTunnel with threads


Basic information

By default, wodSSHTunnel does not use threads. All code is running in the same thread, asynchronously. This is not usually a problem as sockets depend on each other and there is no point having connected clients in separate threads as all connected clients use the same server and all data must pass through that socket. Data is passed through the main server socket as it arrives from the connected user and internal wodSSHTunnel preparation is usually very fast - so your connection speed determines how fast wodSSHTunnel will run.

Apart from the above approach, many programming environments don't support threads or have a difficulty accessing them. VB6 is such an environment - by specification it can only receive callbacks or events from than main thread.

To use threads, all you need to do is set wodTunnel1.Threads = True prior to making a connection with the SSH server.

So why would you need threads at all?

Try not to use them if possible, they will bring you no benefits or improved performance. However a problem may arise when you try to use a blocking method in the same application. Typically, when you want to connect to SQL Server using MSADO components, they will try to Connect and block the thread until connection is established. As wodSSHTunnel lives on the same thread, it will not be able to process internal messages because the other component in your is application blocking it and the connection will fail. This is where threads come in. Even if the component you use will block the main thread, wodSSHTunnel will be able to process the socket messages and the connection will be successfully established.

Problems with Threads=True and using wodTunnelNotify interface

If your environment is not multithreaded, you should be aware that IwodTunnelNotify callbacks are called from whichever thread is necessary. This means that it will also be called from the socket thread and this may cause VB6 to stop responding, so please use events in this case.

Platforms

Windows