PC connection with USB PC

How can I establish a connection between two PCs via USB? I want the program to send numbers via a USB port to another computer on which another program will display these numbers. I have the feeling that this is not possible because the PC is designed for hosts, not devices, but is USB really limited? I really hate that USB does not look like a COM port, which only has an input buffer and an output buffer. You send and receive with ease. I looked at libusb and I could use it, but I cannot find a way to make one PC device. So is this possible?

+5
source share
3 answers

I can not find a way to make one PC device. So is this possible?

, . USB Host- > Device, - Host. USB2USB, , .

LAN. , , Ethernet . TCP/IP .

+5

, USB-to-serial adapter , . COM- , , COM-.

+4

You need to have a USB data cable (also called a USB data cable) that supports the API or SDK, and then use the following code. Communication speed is much faster than using WinSock (TCP / IP) via USB or serial port via USB. The USB2.0 data transfer rate is 480 Mbps, the effective data transfer rate is over 100 Mbps and can isolate viruses and network attacks.

void CU2uDlg::OnOK() 
{
BYTE        buf[65530];
LPU2URET    pU2uRet;
BOOL        bRet;
int         ret;
CString     msgstr;

ret = u2u_open();
if (ret == -1){
    AfxMessageBox("Open U2U device Success.");
}else{
    msgstr.Format("Open U2U device fail,return:%d", ret);
    AfxMessageBox(msgstr);
    return;
}

//send data
bRet = u2u_SendData(buf, 65530, ret);
if(!bRet)
{
    msgstr.Format("Send data error,return:%d", ret);
    AfxMessageBox(msgstr);
    return;
}

//receive data
while (1){
    bRet = u2u_RecvData(recvData, dataLen, ret);
    if( !bRet )
    {
        msgstr.Format("Receive data error,return:%d", ret);
        AfxMessageBox(msgstr);
        u2u_close();
        return;
    }else{
        break;
    }
}
u2u_close();


}

See: Reference1 , Reference2

+3
source

All Articles