Solved

vb.net app. using ipworks ipport avoid multiple connections to ip server

Posted on 2012-03-30
3
445 Views
Last Modified: 2012-06-21
Hello Experts,

I'm working on a VB.net application using IPWorks IPPort component.

I have a main form in my application using IPWorks IPPort component to receive data from an ip-server.
I have several forms in the application, that also should use the the IPPort component to communicate with the ip-server.
I would like to avoid that each forms ipport component creates a connection to the ip-server, but uses the IPPort in the application main form (which is always loaded).
Also when the application receives data from the ip-server, it should be possible to identify to which form the data (send from the ip-server) belongs.

Can somebody help with this?

Kind regards
Thomas
0
Comment
Question by:nielsen_t
  • 2
3 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37795510
Sharing the connection is easy. Put it in a module

>it should be possible to identify to which form the data (send from the ip-server) belongs.

That would be the tricky bit. One option is to maintain the current form name who has sent anything to the server and when the response comes back, you post it to the current form.
0
 

Author Comment

by:nielsen_t
ID: 37798368
CodeCruiser, thanks for the answer.

But when sharing the connection, won't there be issues with synchronization. Eg. if multiple threads accessing the ipport at the same time?

Is it possible to show how to use the ipport within a module?

Regards
Thomas
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37802133
You would need to implement a complex solution to avoid issues when sharing. One option is to implement a queue. Each form calls a function which then queues the request. These is a thread which gets an item from the queue at a time, sends it over, waits for the response, posts the response back to form and then moves on to next item.

>Is it possible to show how to use the ipport within a module?

Just declare it as public/friend inside a modules file (Add New Item->Module)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question