Unfortunately the TCP/IP sockets for the serial ports won't do telnet negotiation, so one gets a connection with local editing and local echo, which is annoying to use. Of course one can tell most telnet clients to use character mode, but theses things can be automated very easily. In the COM port settings for TCP/IP sockets add a selection 'raw' and 'telnet'. If set to telnet the following function will negotiate a proper setting for telnet clients, kermit and whatever:
Code: Select all
/*
* do the telnet option negotiation
*/
void telnet_negotiation(int fd)
{
static char will_echo[3] = {255, 251, 1};
static char char_mode[3] = {255, 251, 3};
struct pollfd p[1];
BYTE c[3];
/* send the telnet options we need */
write(fd, &char_mode, 3);
write(fd, &will_echo, 3);
/* and reject all others offered */
p[0].fd = fd;
p[0].events = POLLIN;
while (1) {
/* wait for input */
p[0].revents = 0;
poll(p, 1, TELNET_TIMEOUT);
/* done if no more input */
if (! p[0].revents)
break;
/* else read the option */
read(fd, &c, 3);
//printf("telnet: %d %d %d\r\n", c[0], c[1], c[2]);
if (c[2] == 1 || c[2] == 3)
continue; /* ignore answers to our requests */
if (c[1] == 251) /* and reject other options */
c[1] = 254;
else if (c[1] == 253)
c[1] = 252;
write(fd, &c, 3);
}
}
Code needs to be read with RFC for telnet negotiation close by. This is the implementation I use for my Z80/8080 virtual machines from the z80pack project. (google it, I may not post URLs).
Code is under BSD license, can be used under MIT license or whatever you need, I really don't care.
With that in place it is much more comfortable to telnet into VMs running some sort of UNIX. This is a really small change and it would make using Virtualbox more comfortable for me, probably for others too, so thanks in advance.