Socket programming and telnet with VB.net - 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.

Related

How to send UDP/art-net command to LANBOX LCX in the same network?

I have a LANBOX LCX device which is used for lighting up a few dimmable bulbs which are connected via DMX cables.
I have read the documentation and tried to find ways to send UDP, but as I am a newbie in lighting and DMX world, it is so hard to understand it.
Documentation: http://support.lanbox.com/Manuals/LanBox%20Reference%203.04.pdf
I have also tried some art-net programs to send data through that and also sending the mentioned bytes via UDP also. But none of them worked.
There are not much online resources also for this area.
If someone with knowledge about this particular area can help me, it would be really helpful.
If someone can help me with either sending art-net or UDP commands to the device to dim specific lights and light up specific lights, it will be really helpful.
Tried with the following documentations and GitHub repos:
https://www.artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf
http://support.lanbox.com/Manuals/LanBox%20Reference%203.04.pdf
https://github.com/MikeCodesDotNet/ArtNet.Net
https://pypi.org/project/pyartnet/
I wanted to change the values in the DMX monitor, but it doesn't change.
I share your pain, however I have spend a lot of time building library's for various applications to interface with Lanbox (node.js, Bright Script etc) and so I know everything there is to know about Lanbox (including the bugs)
you have found the correct ref docs
you need to connect via TCP
after you connect it will ask for a password , send this , it is default 777
then to edit channels direct you need to look at the command
#C9 ChannelSetData
make sure you check out the command
#65 Common16BitMode
as a lot of the docs ref 16 bit mode but when you connect it will be in 8bit mode so if you need int above 255 you have to set it into 16bit
let me know if you need more help, when i do lanbox training it takes a few hours to full explain how they work so its understandable if you are totally confused

Can I poll my USB HID device without first sending a command

I was able to make a working HID USB stack on my "StartUSB for PIC" board for the 18F2550 microcontroller. I based it on one of the MLA libraries, which was made for the 18F45K50 (MLA 2018_11_26, hid_custom, picdem_fs_usb_k50.x), but I converted it to work with the 18F2550 (there might have been easier ways, but only learned to work with PIC about 1 month ago). On the host side, I'm using LibUsbDotNet (also here, there might be easier ways - the documentation on this library really sucks) on a Windows 10 machine.
I'm using the HID class, full speed, and all seems to work. Although, I get some random errors on the host PC (see below), but doing one close/re-open cycle on the host side when getting the error is kind of solving it. Dirty, but it works. So I kind of ignore this now.
Win32Error:Win32Error:GetOverlappedResult Ep 0x01
995:The I/O operation has been aborted because of either a thread exit or an application request.
I'm not an expert on USB (yet). But all examples I'm seeing are based on 1) you send first a command to the device and 2) then you retrieve the answer from the device. I did some performance tests, and see that this indeed shows that I can do about 500 cycles/second. I think that is correct, because each cycle, sending command and retrieving answer, each takes 1 msec.
But do I really need to send a command? Can't I just keep reading endlessly, and when the device has somthing to say, it does send the data in an IN transaction, and when not it ignores which creates a timeout on the host side. That would mean that I can poll at 1000 cycles/second? Unfortunately, I have tried it by changing my implementation on the PIC, but I get very weird results. I think I have issues with suspend mode. That brings me to another question - how can I make the device get out of suspend mode (means that not the host, but the device should be triggering this event). I have searched the MLA library for command such as "wakeup", "resume", ... but couldn't find anything.
So, to summarize, 2 questions:
Conceptual: Can I send data from device to host without being requested for it by a command from the host?
For PIC experts: How can I have a device trigger for a wakeup from suspend mode?
And indeed, the answer is Yes on the first question.
In the meantime, I found another link on the web that contains a Visual Studio C# implementation of a USB library including all the source files.
If you're interested, this is the link
This C# host implementation works as a charm. Without sending a command to the device, I get notified immediately if a button is pressed. Great!
It also proofs that my earlier device implementation based on the original MicroChip MLA, is 100% correct. I stress tested the implementation by sending a "toggle LED command" as fast as I could, and I reach 1000 commands/second. Again great!
I think that LibUsbDotNet isn't that perfect after all. As I wrote above, I get rather unstable communication (Win32Error). But with this implementation, I don't get a single error, even after running for half an hour # 1000 commands/second.
So for me, case closed.

WAN/GAN IM application in VB.net

Hi I have started a project which connects to a database and creates/logs in a user at the moment i have a LAN messenger that works very well, and a FTP chat which is not exactly what i was hoping for.
my idea now is to create two tables in the database message 1 and message 2 both of which display the user who is sending and the message sent. and the program uses threading to connect and download the messages.
My question is, is there a better way of completing this task (if so could you send a link or two this way? or express your opinion).
and or any problems you guys/girls think i would run into. Cheers :D
If you require to see some code just ask and i'll edit the post thanks
Although its easy on paper to do a chat application that uses a 'DB' as a backend/comms layer .. its not really the best approach. It will work... but with load, it may not be a very good approach.
Most chat clients uses a peer to peer connection, or even client server with the coding and implementation of a server that handles what happens with messages going/destined where ever.
If you really want to get low down and dirty, google for 'TCP chat application' examples. If you want to operate a bit higher (not handle the really gritty low down mechanics), then look for some 'wcf chat' examples.

Best iOS Framework for Advanced network usage?

I need a network framework that can post raw data such as 0x01. or any raw data i need posted to a server. Not just a HTTP request. I can't seem to find any network frameworks like this. Also, If there are none that currently exist. How would i go about writing the sockets? I can't seem to get that down. which is why i am looking for a existing framework. Thanks for any help. I have tried using sockets but, I was unable to convert the CFArrayRef. I tried many things, But, It crashed every time i tested. So, I am running out of options but to use a prebuilt framework.
Note, I do not want to do only a request like:
POST / HTTP/1.1
Host: localhost
Content-Length: 4
0x01
No, I would like to send RAW data so, The following would be sent to the remote server through a socket.
0x01
This would not be visible raw text however, It would be converted to a data string then sent. I know how to convert most of the stuff i need to do, Its the sending and receiving the response I need the framework for or something that'd work. Any tutorials online or examples on how to do something similar that I can modify to fit to my needs would be greatly appreciated.
How do i send raw data to a socket?
Where do i find a framework like this?
Can you provide tutorials that I can modify to fit my needs?
The best framework for this is CocoaAsyncSocket. While it allows sending arbitrary data on the socket, it also provides very useful abstraction of much of the busywork of socket management. Look particularly a the GCD version that replaces the older RunLoop based code.
I've built several low-level protocols on this stack. I recommend it highly.
You can either use raw sockets or the CFStream API. I recommend the latter.

Sample Code for Remote Process/Application Monitoring

All
I am looking for a bit of inspiration here, a client has requested me to build a simple remote process monitoring application with capability for smtp notification, when monitored processes go down or come back on-line. Can anyone point me in the direction of some sample code to get me started. I have briefly looked at .net remoting as a potential development path, from my understanding of how this works, the remoting architecture would require both a client and remote server component, (though I am not a 100% sure on this one), however if this is the case, then it will not fit the bill, as one of the fundamental requirements is that no additional software can be deployed on the servers which are to be monitored.
Alternatively, if you know of a finished 'lightweight' product out there, which would deliver this sort of functionality then this would probably work as well.
Kind Regards
Paul J.
Net-SNMP actually has the ability to monitor processes and send out notifications now. If you look in the snmpd.conf manual page (http://www.net-snmp.org/docs/man/snmpd.conf.html) under "process monitoring" (http://www.net-snmp.org/docs/man/snmpd.conf.html#lbAR) and "disman event-mib" support (http://www.net-snmp.org/docs/man/snmpd.conf.html#lbAX) to get the two features you need. Also the notification sending support (http://www.net-snmp.org/docs/man/snmpd.conf.html#lbAW).
I don't remember the windows support for it and how well it works though (it looks like you're aiming for windows).