问题
We have a solution where some hardware connects to a COM port on a Win 7 machine, and interacts with our Java app. The hardware wants to use a PPP Server to transparently connect to an other server over TCP/IP.
Does anyone have a suggestion on how to do this? Start an OS native PPP Server from the Java app, with a connection to the COM port? How is this done?
回答1:
You may be surprised to find that Win7 still supports PPP natively.
Follow these steps (or something like them) and you should be mostly good to go. I haven't actually performed a PPP connection since probably Win98, maybe Win2k, but the steps look to be pretty similar to what they were back them. It's not straightforward, but these should get you 80 or 90% of the way (the last 10-20% will be the normal hair-pulling irritations of getting the serial connection properly configured - there are way too many options involved in serial communications and PPP for it to go right on the first connection attempt).
- Open Control Panel
- Select "Phone and Modem". If it asks you about location, type in whatever information you need to make that dialog box happy (I think it just needs your area code, but maybe not, or maybe other stuff - it doesn't matter we won't be using it).
- Tell it you want to install a modem, and don't worry that if can't find one - you'll be selecting one from a list.
- Click the "Add" button, and tell it not to bother detecting one automatically
- Under "(Standard Modem Types)" select the "Communications cable between two computers"
- tell it what serial port to use
Now you need to set up the 'network adapter' for the PPP connection
- go to the "Network and Sharing Center" of Control Panel
- Click on "Set up a new connection or network"
- Select "Set up a dial-up connection"
- If it asks you about what modem to use, select the "Communications cable between two computers modem" that you just set up (this shouldn't happen unless you have an actual modem in your computer).
- Give the "Create a Dial-up Connection" dialog box a bogus phone number so it will let you continue... And give it a connection name that you like instead of "Dial-up Connection"
- Click "Connect" and it'll try to dial. Of course it'll fail. Click "Set up the connection anyway"
Now configure various PPP settings on the new network adapter:
- Click on the "change adapter setting" link in the "Network and Sharing Center" control panel
- Right click on the network adapter that you just created ("Dial-up Connection" or whatever name you gave it), and select "Properties"
- Configure the "Communications cable between two computers" (mainly this lets you set the speed). Look through the other tabs for the various other options you might need to control. Don't forget to configure the TCP/IPv4 properties that you might need on the "Networking" tab. If you're using IPv6, make sure that stuff is configured too.
Once the hardware device establishes a PPP connection to the Win7 COM port, the Java application should be able to communicate over the PPP link as if it were a regular network adapter. Good Luck!
回答2:
Using Google on the basis of @hari comment about javax.comm
I found a tutorial on TINI, which may be useful on your purposes: the guide takes a PPP connection through COM port with TINI library equally as you want to do.
来源:https://stackoverflow.com/questions/7011384/ppp-server-on-windows