client to server communication in VB.net - vb.net

I made some code in vb.net which checks if a certain process is running, and returns a 1 if it is, or a 0 if it isn't. Now I want it to send a packet to my server or something which would log the IP of the client, or something similar.
What would be the easiest way to approach this?

There are a lot of different solutions to this task. First, which comes to my mind is WCF - maybe the easiest one as you do not think about opening ports, establishing the connections, parsing the input socket string and so on.
Here is on more link:
Introducing Windows Communication Foundation in .NET Framework 4

Related

How can I tell if my SignalR Backplane (Redis) is really working as it should?

I'm currently playing SignalR 2.0.3, scaling out with a BackPlane that utilizes Redis for windows
http://msopentech.com/blog/2013/04/22/redis-on-windows-stable-and-reliable/
I've integrated with the appropriate SignalR.Redis package in VS.
I made the following changes to my startup:
GlobalHost.DependencyResolver.UseRedis(
server: "localhost",
port: 6379,
password: string.Empty,
eventKey: "BroadcasterExample"
);
app.MapSignalR(hubConfiguration);
It builds fine.
My client appear to connect OK.
I can send notifications between client & server and visa versa.
From the Redis-client, I can enter:
get BroadcasterExample
which returns: "3"
I assume that things are working, but...
A couple of question:
1) How can I tell that is actually working?
2) What can I examine on the Redis server (though the Redis-client)?
3) What is getting stored in what data structures (key/value pairs, lists, hashes, sets)?
I would like a little more in depth view as to what is going on.
I've looked at the commands on: http://redis.io/commands
Nothing is jumping out at me which will help me map what's really going on.
Can someone point me in the right direction here?
Thanks,
JohnB
1) I believe you have already verified that it was working when you ran "get BroadcasterExample" and it returned "3". BroadcasterExample is the name of the channel that SignalR will send messages over and I believe the 3 represents the number of messages that have been processed. As you send more messages with SignalR you should see that number increment.
2) A good way to tell that things are working is to subscribe to the BroadcasterExample channel with the redis client and watch the messages come through. From the client, run:
subscribe BroadcasterExample
3) SignalR will probably just store that one key, the "BroadcasterExample" key. SignalR is really just using the publish/subscribe functionality of Redis, not storing any data.
The answer from jaggedaz has useful info. I would also add that you can do a different tyope of test quite quickly by hosting your application twice, under 2 differents ports, using IIS Express. If you then connect 2 browser windows to these 2 different instances and start exchanging messages (like broadcasts to All), you will see them flow across both clients, which is possible only when the backplane is actually working.

WCF duplex with DHCP?

I'm using a duplex WCF contract in this chat-like application that i have running. (obviously not really a chat, but for the interest of thinking about it you can assume it's similar enough).
the problem is that many of the clients that talk over this contract are running dhcp, and there's not really anything i can do about this.
What's the best way to handle duplex communication with dhcp? I found a setting <compositeDuplex clientBaseAddress="Uri"/> which means i could update this value at runtime.... seems a bit kludgy.
Update
I found that in my WCF server logs, part of the problem is that it was putting hostname in the response address. what am i doing wrong here?
thanks
To be blunt, the first thing that you're doing wrong is using DualHttpBinding to do duplex. That whole binding is a giant kludge and is prone to problems like this (and firewalls, oh god firewalls).
If you were to use something like net.tcp instead then the clients establish a single bidirectional connection to the server instead of needing two connections, and thus the server doesn't care if the client is on DHCP anymore.

Asynchronous socket programming

I'm creating an asynchronous socket programming in vb.net. i've utilised the code from Asynchronous client and server code from the following links:
http://msdn.microsoft.com/en-us/library/fx6588te.aspx for server program
The client program is present as per http://msdn.microsoft.com/en-us/library/bew39x2a.aspx.
When I try to connect the for more than one client the second client always waits until the first client completes the call. I want the clients to accept calls at the same time.
Does WCF help to make multiple clients to accept calls at the same time? If so what is WCF and how will it help. Or is there any other concept which can help?
Yes, WCF can help you there. But it implements only well known protocols like SOAP, WS-*, JSON, and a few proprietary ones like binary TCP binding.
You'd only use async socket programming if you need
High scalability (more than 20 simultaneous clients)
A custom protocol
If you build on top of HTTP, I recommend the HttpListener class
If you need a custom protocol with a few clients, use synchronous socket programming with multiple threads.
If you still want to implement a server with async sockets, then you need a continuous loop that accepts connections (after EndAccept() immediately call BeginAccept() again) and then start the BeginReceive()
I can tell you from experience though that debugging such a server is not easy. It's quite hard to follow the chain of events even through a detailed log file. Good luck with that :)

Socket programming and telnet with VB.net

I'm writing a GUI-based app in VB.net that talks to a LambdaMOO server via telnet, sends commands to display the object hierarchy, then parses the output and creates a visual representation of the object hierarchy.
So my question is: is there some kind of "telnet client" class for .NET to simplify the sending and receiving of data, or do I have to write my own using the socket API?
Does Mono have something like this?
Barring an easy solution, does anyone have a good tutorial they can point to for telnet client programming in VB.net?
Ok, I had a similar issue and ignoring all security complications and the like, wanted to TELNET from a VB initiated connection to a remote device and do stuff. I concur that the whole negotiation process is a hellish thing to do but once you've worked it out it's actually pretty simple to implement. I decided not to stop because I kept reading things that said it couldn't be done when it clearly can be done if you can write and read 1's and 0's into/from a network stream.
The code in the link below will initiate the connection and get you through to actually exchanging clear text information over TELNET. Given the example of sending a username and password combo shows how to read and write to the connection.
Big tips - initially have a nice big textbox or something to trap everything that comes into the buffer (variable returndata). This will help you diagnose problems. Also check on my blog there how to do this without the textbox blinking like a flashing thing. Once you've done all that and you know your script is reliable, trun off any screen updates and it will whizz through rather than take an age.
Apologies for the really dirty code and the crappy website layout.
http://myhead-online.blogspot.com/2009/05/vb-net2008-express-telnet-to-sun.html
The telnet protocol is basically just the usual TCP protocol, with a bunch of optional stuff that you probably won't need to implement. So you'd open a socket and start sending and receiving data with the socket stream interface.
Give it a try with the regular socket API, you'll probably find that it's quite straightforward.
just a suggestion. you may try to program your vb application to execute an existing telnet application in batch mode.
here is the link for your reference. refer to 7.3 Using Plink in batch files and scripts. Hope it helps.
You can grab one of any number of libraries to use. Here's one library:
LINK
For others try googling something along the lines of: library telnet mud .NET
Lastly, there are any number of opensource MUD/MOO/MUSH projects open at any time who are willing the share ideas and looking for people to help with projects.
I had my trials with telnet. You've to use tools like wireshark in conjuntion to figure out what commands needs to be initiated. I did find communicating with my unix box quite a challenge. For one thing you must know your telnet instructions. You might find it difficult to determined the state of the application - whether it is logged in or not innately. You'd have to formulate your own logic for it.
Another thing you'd have to do is parse the bytes returned by telnet into commands or instruction data i.e. you have to know if the bytes received is an instruction or some other thing it is trying to send you. Here is a ref that would come in handy.
First I suggest you start using the wireshark tool and get the communications send to and fro manually as well as via application.
From the LambdaMOO end of things, if you have wizard access or are friends with someone who does, you can have the MOO give you the data over another protocol that you might be able to work with more readily, such as HTTP. All you need is an object on the MOO with a do_login_command() set to handle requests, and then use the listen() builtin to get that object to listen on a given port. As long as a protocol doesn't require anything complex SSL, it's fairly easy to code up on the MOO end. So that might be worthwhile if VB.net has easier handling for HTTP etc.

vb.net possible to monitor raise events across applications?

I may have gone crazy... but I am hoping there is a way to do this.
I have a base class that has event handling in it. My console application is running my workflow. Part of that workflow is to raise events at specific intervals in a separate thread to broadcast the workers' current state (a heartbeat I have heard many call it).
I also have another program in the same solution that is a windows form that I want it to be able to listen to what is going on in the console application so that it can display the worker states. I have tried running both at the same time and verified the events are triggering, but the monitor is not finding any of the raised events.
I am fearing that there is no way to do this, and I will need to go to a database logging method or something else... but in the off chance someone knew how to communicate between applications with event (or event-style) logic, I would appreciate it.
Currently the applications are running from the same location. The goal is that the monitor application will eventually be attached with a broadcaster for our network so that our workstations can monitor for certain worker states without being logged into the machine and the main monitor will show us the full status of all the workers.
Please let me know if I need to expand/clarify this, have a 2-year old watching Star Wars while I type this so I may have missed something.
There are several ways: using remoting, custom windows messages and named pipes. One way is How to use named pipes for interprocess communication in Visual Basic .NET or in Visual Basic 2005
Here's a remoting example: Simple Inter-Process Communication In VB.Net
Here an example of custom windows messages: VB.NET, VB6 and C# Interprocess communication via Window Messaging
Perhaps the most 'up-to-date' way is to use WCF Callback Channels: Using Callback Contracts in WCF for Asynchronous Publish/Subscribe Event-Style Communication