How to test a VB program which will run on a network - vb.net

I am a self-taught programmer and have only delved into new areas of programming as the need arises. I have never done any network programming, everything I have written has been for a single computer. I have written a program for an old board game and it runs great. But, now I want to try to write it to run for multiple players across a local network. I have an idea of what has happen in terms of constantly checking a specified folder/file for changes. But... how do you test this without actually building/compiling the program and installing it on another computer every time you make any changes? I have tried to search various forms of what I have as the title here, but all that comes up is about testing network connections, or socket programming (would this be easier/needed) or systemfilewatcher (which may be an option too if it will run on Windows 7 and 10... but, I find nothing about testing programs to actually access the network and simulating 2 copies of the program running. Any suggestions, links, etc. would be greatly appreciated.

I think you will be disappointed in the performance of a file-based network game unless reaction or refresh time is of little consequence for your "board" game. You may also need to work out potential concurrency issues (ie, someone updating a file you've just read). If you have any desire to do other games in the future you should be using sockets (most likely UDP unless you have a good reason not to) to create a client server system.
As to your question, yes, you should be able to test it. You just need to run both a compiled exe and the source in VS debug mode, accessing the same folder on your drive. If you go with the socket-based option, you would use your PC's loopback address 127.0.0.1 (sometimes known as localhost), but the 2 different parts will need to communicate on different ports.

Related

needed : Program for easily switching developer environment

This might be the wrong forum, but its filled with so many smart people so someone might know a solution.
One of my customers has given me several assignments that require a quite similar yet wery different development setup (different versions of class-libraries and such) and the problem is that each time I need to switch between the projects I need to do a lot of configuring to get the compilation to work and not include wrong versions of tools used.
If I dont get it right there might be a lot of cleanup afterwards.
It takes me at least an hour to switch projects. Often several.
Now I realize that the customer has an issue with a lot of branching in their setup and they are working on that, but thats a long process.
So.. My question is. Is there some tool that allows me to take "snapshots" of working project-environments and switch between them?
I'm working on windows.
There are many options. One of them is virtualization: running an entire operating system on top of your operating system. It will emulate a fake hard drive, fake network card, etc. This will run an entire desktop 'in a box'.
In the last years containerization is very popular: running a separate environment (file system, OS configuration) but leaving the heavy stuff to the host (in your case, Windows) such as networking, hardware, etc. This is geared towards running a single application (though this is flexible) 'in a box'.
In your case, since you need to encapsulate an entire development environment, it would seem to be best to go with a virtual machine.
A no-cost solution is Virtualbox. Paid alternatives such as VMWare may offer better usability, performance or features.
If your class libraries are in a specific location, you could containerize the compiler: you work on your PC, then build inside of a 'box' with its own environment. Docker is often used.
Depending on what language you are programming in, there may be a specific solution. Python has VirtualEnv, for example.

UPnP in visual basic: Does is still work?

tl;dr - I'm attempting to open internal and external port 4305 to my local address at 192.168.1.103 through UPnP with Visual Basic code.
I've been searching for the better part of 20 hours looking for a way to open these ports on my router through UPnP code for VB. So far, nothing has enabled me to trigger a port through VB. To keep a long story short, I've attempted about 4.3 different options with varying success. These are:
Microsoft's Interop/COM NATUPnP Library (https://learn.microsoft.com/en-gb/previous-versions/windows/desktop/ics/network-address-translation-traversal-interfaces)
NetworkLight_VB (An old program I hoped I could use for reference, http://www.thijsschreijer.nl/blog/?p=450)
ManagedUPnP Library (This is the .3, I spent little time exploring this lib as it's C#, but still think it's worth mentioning, https://archive.codeplex.com/?p=managedupnp)
UPnPc/MiniUPnPc (http://miniupnp.free.fr/)
Portmapper (https://github.com/kaklakariada/portmapper)
NATUPnP 1.0 Type Library
Having a little prior knowledge with Interop services through excel based programs, this seemed like a pretty good solution, however it didn't get very far as the COM object NATUPNPLib.IStaticPortMappingCollection would always return as nothing. I imagine this would be due to NATUPNPLib.UPnPNAT also returning empty, despite Visual Studio showing it as an initialised COM object. With little info or guidance other than "Your UPnP is probably off" (It wasn't) I decided to see if there was another way, and moved on.
NetworkLight_VB
In an attempt to look for working examples of UPnP triggering through VB I quickly realised that this isn't a very hot topic and has barely been talked about in years, with this program being no exception. Opening the program it seemed to run fine, though I had no indication of it actually working as intended, with my router showing no UPnP activity on the port it was trying to hit. I believe there's still potential here with the library being used, but I'm not sure how to utilise it properly or reference it within my own program.
ManagedUPnP Library
This is the same as with the UPnP library used by the NetworkLight_VB program; not sure how to use it. (Being entirely self taught, my knowledge foundations are shaky at best. The only references I've used successfully are through Visual Studios 'add reference' option like with the NATUPnP Interop service)
UPnPc/MiniUPnPc
This showed a lot of promise as a potential workaround, allowing the use of a stealth CMD window to do the dirty work, but this also failed. The worst part is that I have no idea why. Running it seemed to work without issue, and it echoed a success in triggering UPnP, however my router told me otherwise. Checking the UPnP list showed no open port, and any attempt to communicate between my host and client programs failed.
By this point I was ready to just give up and port forward manually. Surely, if everything I was trying kept failing then there must be something wrong with my setup, computer, something that was misbehaving. But I gave it one more shot.
Portmapper
This nifty little java program worked like a charm. I entered the info, checked my router wizard and, lo and behold, there was the port sitting open and ready. Testing my client and host programs, I confirmed that it was working exactly the way I wanted it to. There was just one problem: getting it into my program. Browsing the author's website I found that it did in fact have a command line interface with examples, though my pitiful (and very tired) attempts to use that CLI didn't work. This shouldn't be too hard to work out though.
What does bother me however is that it needs Java installed on the computer to run, and since this is a peer-to-peer based program, replacing 'asking a user to port forward' with 'asking a user to install Java' is undesirable (Though, if all else fails, then so be it. Pressing install is far easier than navigating a router gateway wizard).
Ideally I would like to have the NATUPnP Interop service or any of the libraries work so that I'm not running code outside of the main program, but I really want this to work so anything that does is probably what I'll use.
Any guides on how to use the libraries, examples of working programs or suggestions on alternative methods is very much appreciated.

Why is it better to use Vagrant instead of sharing the VM's Disk itself?

I was searching for the best way to distribute a development environment to my team and found Vagrant.
After some reading and testing, here is what I can say about it
Pro:
Automates the process of creating a new VirtualBox VM (for a new user).
Con:
Nullifies the only pro I found by requiring the new user to learn a new tool.
The learning curve is way more time expensive than actually copying the VDI and configuring a new VirtualBox VM tu use it.
(It is not that great as well, but is still higher than learning a new tool.)
I definitely didn't understand why using Vagrant makes the process of distributing a development environment so different than just creating a normal VirtualBox VM and sharing the disk.
Maybe I'm missing a point here, can anyone enlight me?
I can only speak from my own experience: the learning curve is well worth it.
As a programmer, I love being able to set up separate isolated environments for development, testing, and deployment.
Sure, you can copy the VDI around and whatever, but it's easier-- in my opinion-- to execute a few command line programs and it's all ready to go. It just seems dirty to me to copy around VDIs or other types of images.
Also, I can make packaged up vagrant boxes that I can send to my coworkers or distribute on the Internet.
There are a lot more advantages to vagrant than just that:
100% reproducible environments, everywhere the same.
Can be stored in source control (git/svn/...) and versioned.
Saves diskspace. This can be important on laptops, I right now have 92 Vagrantfiles on my system, not all created. Imagine them all being full blown 20gb vm's...
Experimentation becomes trivial. A quick vagrant init precise64, vagrant up, try some stuff, vagrant destroy, vagrant up, retry some stuff, vagrant destroy - and done.
It requires some discipline not to install required packages manually or updating the common Vagrantfile when doing so, but once you have a workflow worked out, it's simply brilliant. I find
I think the major advantage of Vagrant is that it let's you have one base package that can be re-configured for different purposes covering dev, testing, management, operations, etc. simply by changing the manifest/cookbook. It's just more convenient to share and start up.
Less major, but still nice is that it lets you start over effortlessly. I know you can use snapshots in VirtualBox, but sometimes, it becomes annoying to keep going back and forth between them. With Vagrant, you can start a box, test some things, destroy it. Than you can start again, the same box, test something. You can start twice the same VM easily, and test slightly differently in each, destroy them.
Also check out the answer here: https://superuser.com/questions/584100/why-should-i-use-vagrant-instead-of-just-virtualbox
EDIT: In my first answer, I was thinking of Packer, not Vagrant, my mistake.
We are discussing the same question in the office... Right now, btw!
When I first got in touch with vagrant, I was sceptic, but the advantages I could see, beyond personal opinion is:
you can start from a common configuration and automatize many "forks", without a snapshot-chaining (what is a big pain when you need to delete one snapshot or two, I might say);
the process of cloning (packing) a machine is way faster than export appliance;
using vagrant to setup a machine still makes you able to use VBox iface, so no problem to make a start point based on Vagrant's features and let the teammates decide if they will use it or not;
as said, automatization.
We are still making some tests... Now talking about particular opinion, to me the main point is replication and the fact that packing and unpacking is faster than exports.

How can I run an .exe on a server, but show output and interact client-side?

I want to run an .exe (Halo to be specific) on a server and then be able to view and interact with it through a browser, similar to a remote desktop. Is this even possible? I want to do this because we have nothing left to do in the last few days of school, and we wanted to play a Halo LAN, but are not allowed to install anything on the computer or run anything off of a flash drive, thus this was an idea we came up with.
Well, in principle it would be possible (though performance would probably be a problem), but in order to do this, you'd need at least some kind of viewer on the client. This in turn would need to be installed :-).
You could try to set up a VNC server, then use the TightVNC java viewer. That would work if the school's computers have Java set up. Still, I don't believe you'd get usable performance (VNC typically gives you 1 FPS at best).
Your best option is to either play browser games, or just do something else with your time. You might even try studying something interesting :-).
There is a way, and it's called CGI, but you won't be running Halo with it anytime soon.

How do you automate some routine actions for improving productivity? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Every morning, after logging into your machine, you do a variety of routine stuffs.
The list can include stuffs like opening/checking your email clients, rss readers, launching visual studio, running some business apps, typing some replies, getting latest version from Source Control, compiling, connecting to a different domain etc. To a big extend, we can automate using scripting solutions like AutoIt, nightly jobs etc.
I would love to hear from you geeks out there for the list of stuffs you found doing repeatedly and how you solved it by automating it. Any cool tips?
I use Linux. I have a bunch of scripts that do anything I want. Typically I write a script whenever a "block" of work can be reused in the future. For example, simple refactorings, deployments, etc...
Over time I started to combine these blocks, hence getting ever more efficient.
Regarding the "load stuff at startup", under Linux that comes out of the box (you can "save your current session" when you log out or turn off the computer).
On windows, my suggestion is to use programs that can be automated via command line.
A favorite way is to leave the computer on at night or better, if it's a laptop, put it to sleep. Running a web browsing virtual machine in VMware or similar works also, you can set the VM start along with the machine and save its state on shutdown, so your web pages and email client stay open. This works for development also if you're doing scripting or something similar where the performance hit of the VM on large compiles won't negate the benefits.
SlickRun is very handy for this, just a few keys to navigate to anything common and a very small footprint. With input variables and file path recognition all part of it I can quick remote desktop to any machine, search anything, pull up whatever's needed.
On OS X, I have an Applescript that I run at the beginning of the day. It sets an away message on IM, hides or quits programs that would distract me, gets new mail, and so forth. I also plug in my USB backup disk, so when I'm going home, another script ejects it and quits some programs. When the script is done, so am I.
I invoke these scripts with key combos using Quicksilver.
If you don't have a Mac, by the way, Quicksilver and Applescript are probably the #1 and #2 reasons to switch. Between the two of them, you can tell your computer to do practically anything you want in very short order.
Use a good app launcher such as Quicksilver or Launchy to cut down on the time it takes to perform simple tasks. They're usually not scriptable, but they do let you do each step faster.
Writing shell scripts (Applescript, Bash, PowerShell, etc..) is a great way to automate most mundane tasks, assuming your apps are scriptable, as well as pick up a new language. As you venture further into this practice, you'll find yourself more and more annoyed at the apps you use that aren't scriptable, to the point where it starts to affect your choice of apps ;-)
Also, consider a cron job, Windows scheduled task, or similar OS X analog to automatically run certain tasks at certain times of day/week/month/year. You can use this for anything from the "workday morning" scripts mentioned previously, to reminding you of your wife's birthday and anniversary every year. There's some more info here for *NIX systems, or here for Windows boxes.
Happy automation!
I have a hard time wrapping my head around Applescript, but since Apple runs BASH scripts just fine, I just use those instead. I've got a development server on my mac, so I've got a script that I can run to create a new site directory, create a new virtual host in apache, add a new domain to my /etc/hosts file, etc.
It's especially cool to integrate Bash (or probably applescript, although I don't know how) with Growl. That way, you can put a nice message up on the screen, complete with a png icon. This is more useful for things that your scripts do during the day though.
I do most of my programming work on a development server at work, so in the evening I simply detach my screen session and re-attach it in the morning, so it takes just a few seconds until I'm exactly where I left the day before.
I have some macros defined in mutt to clean up my inbox (archive commit mails etc.), I have a script that mounts some directories on the development server on my notebook via sshfs (works without interaction using public keys), and after that all I have to do is start up a browser and get a coffee. :)