serial port using tcp not working

Discussions related to using VirtualBox on Windows hosts.
Post Reply
seaudi
Posts: 1
Joined: 28. Nov 2015, 17:32

serial port using tcp not working

Post by seaudi »

Hi,

I tried using serial port in tcp mode, I unchecked "connect to existing pipe/socket", then put the tcp port 3000 in the text box under it. but I could not find any port listening for telnet. i tried telnetting to localhost:3000, 127.0.0.1:3000, or the real host ip address 192.168.1.8:3000, but nothing.

I tried again but his time checking "connect to existing pipe/socket", and still the same.

I need to run a VM on a HOST_A, and i need to telnet into this VM from HOST_B using "telnet HOST_A_LAN_IP:HOST_A_TCP_PORT:.

How can i do this ?

My Virtualbox version is 5.0.10 r104061.

Thanks
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: serial port using tcp not working

Post by scottgus1 »

I'm not certain if you have to use the serial port for your experiments, if so others will have to help.

But if you want to communicate between two guests running on different hosts, I'd say Virtualbox's Bridged networking would be easiest. See the manual on virtual networking section 6. Bridged will make your guests appear as if they are other PCs on your network, so your network will see four PCs from the two hosts and two guests. You would access the guests by their IP address given out by the DHCP server on the network, or by static IP address you set in the guest OS.

If you really need to use "HOST_A_LAN_IP:HOST_A_TCP_PORT" you could try setting the guest to NAT and set up a port forward.
dldall
Posts: 6
Joined: 18. Jan 2016, 14:33

Re: serial port using tcp not working

Post by dldall »

seaudi wrote:but nothing.
i can confirm, the TCP access to serial port is not working.

Code: Select all

C:\>netstat -a -p tcp -o -n
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       888
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:49152          0.0.0.0:0              LISTENING       596
  TCP    0.0.0.0:49153          0.0.0.0:0              LISTENING       1088
  TCP    0.0.0.0:49154          0.0.0.0:0              LISTENING       700
  TCP    0.0.0.0:49155          0.0.0.0:0              LISTENING       1180
  TCP    0.0.0.0:49156          0.0.0.0:0              LISTENING       692
  TCP    0.0.0.0:49157          0.0.0.0:0              LISTENING       1544
  TCP    192.168.1.49:139       0.0.0.0:0              LISTENING       4
  TCP    192.168.101.1:139      0.0.0.0:0              LISTENING       4
*192.168.101.0 is host only network
*192.168.1.49 is way to default gate
there is no TCP port created when VM is runnig
and there are no any error messages during start.
Silence.

In conjunction with hardness of unblocked access to pipes in windows
http://forums.virtualbox.org/viewtopic.php?f=9&t=75776
it is unable to access to serial port at all

if you have a problems with creating socket instead of pipe,
i think to recover
- the easy way is to create second pipe when you run VM (named with .2 ext for example) to deal with threads inside your VBox, not in user programs.
- and the better way is to create TCP socket in 127.0.0.1 host any_port, suitable to single telnet connection.

i do not insist but it looks like much easy to create the TCP socket than elaborate a paravirtualisation stuff.
dldall
Posts: 6
Joined: 18. Jan 2016, 14:33

Re: serial port using tcp not working

Post by dldall »

In comparison with vmwaregateway, that creates TCP socket 567

Code: Select all

C:\>netstat -a -p tcp -o -n -b 
  TCP    0.0.0.0:567            0.0.0.0:0              LISTENING       3588
 [vmwaregateway.exe]
but vmwaregateway test tool gives you only one COM port for all VMs in VirtualBox.

PS:
i decided to view logs to find possible errors

Code: Select all

VirtualBox VM 5.0.12 r104815 win.x86 (Dec 18 2015 16:19:01) release log
00:00:01.164476 Log opened 2016-02-24T18:58:06.662837100Z
00:00:01.164477 Build Type: release
00:00:01.164480 OS Product: Windows 7
00:00:01.164482 OS Release: 6.1.7601
00:00:01.164483 OS Service Pack: 1
00:00:01.220929 Executable: C:\Program Files\Oracle\VirtualBox\VirtualBox.exe
00:00:01.220930 Process ID: 2972
00:00:01.220930 Package type: WINDOWS_32BITS_GENERIC
00:00:01.224755 Installed Extension Packs:
00:00:01.224800   Oracle VM VirtualBox Extension Pack (Version: 5.0.12 r104815; VRDE Module: VBoxVRDP)

00:00:02.068779 Serial#0: emulating 16550A
00:00:02.068835 VMSetError: F:\tinderbox\win-5.0\src\VBox\Devices\Serial\DrvTCP.cpp(389) int __cdecl drvTCPConstruct(struct PDMDRVINS *,struct CFGMNODE *,unsigned int); rc=VINF_SUCCESS
00:00:02.068838 VMSetError: DrvTCP#0 failed to create socket
going to src

Code: Select all

    /*
     * Create/Open the socket.
     */
    int s = socket(PF_INET, SOCK_STREAM, 0);
    if (s == -1)
        return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
                                   N_("DrvTCP#%d failed to create socket"), pDrvIns->iInstance);
going to man

Code: Select all

#include <sys/types.h>          /* See NOTES */
       #include <sys/socket.h>

       int socket(int domain, int type, int protocol);

       Normally only a single protocol exists to support a
       particular socket type within a given protocol family, in which case
       protocol can be specified as 0.  However, it is possible that many
       protocols may exist, in which case a particular protocol must be
       specified in this manner.

       For domain AF_INET the following combinations are possible 
       SOCK_STREAM : IPPROTO_TCP

       #include <net/gen/in.h>
#define IPPROTO_TCP		6
means 0 is not good maybe for SOCK_STREAM?

anyway personally i can not compile the VB src (i have no complete version of VS and VB src is not prepared to "change and complie" state).
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: serial port using tcp not working

Post by scottgus1 »

We lowly users are not likely going to be able to use this info to fix the issue. Might be better to get on the Bugtracker or the developer mailing list.
dldall
Posts: 6
Joined: 18. Jan 2016, 14:33

Re: serial port using tcp not working

Post by dldall »

i did bugtrack and i found a temporary solution with very complex by settings tool puTTY

a) every serial line of any VM can be liked with host pipe (Vm creates the pipes)
b) and puTTY can work with pipes as if it is serial line
http://www.haiku-os.org/guides/virtuali ... -debugging

The trick is to use puTTY Serial mode, and replace the COM1 with \\.\pipe\vmwaredebug or whatever you called the pipe in the VirtualBox serial settings.

There are additional serial settings near the end of the preferences where you can set the baud rate to 115200, turn off handshaking and use 8N1 bits.

Then open VirtualBox, and once it is running your VM, the pipe will exist and you can start up PuTTY.
Image
Post Reply