简体   繁体   中英

.Net TCP/IP send character with Ctrl Key modifier

I am interfacing with a piece of hardware via a TCP/IP socket, however the documentation is limited.

At present I can get the response I am after by sending Ctrl+G in Putty which prints as '^G'

How can i replicate this in code? I can send 'G' but I'm not sure how to modify it with 'Ctrl'

Dim buffer = Text.ASCIIEncoding.ASCII.GetBytes(cmd & vbNewLine)
ns.Write(buffer, 0, buffer.Length) 'ns = Network Stream
ns.Flush()

I am working in VB.Net however examples in C# are fine.

The Ctrl button isn't actuall sent, the Ctrl button + a character acts as a shortcut to a number of ASCII control charachters. In this case Ctrl+G sends the (ASCII value 007) control character (printed as ^G)

https://en.wikipedia.org/wiki/Control_character#In_ASCII

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM