虚拟调制解调器类包含一个AT命令解释器(未在此示出,尽管到目前为止,它是本范例中最大的一部分)和网络代码。下面的代码用来设置串口位速率、数据和停止位,以及奇偶位。从中可以看出,处理入站连接是何等简单:
/**Creates a new VirtualModem connected tO a serial port On
*one end and a TCP port On the data side.
*serial--the serial port this VirmalModem talks tO.
*speed--the speed the serial port should be Set tO.
*tcpport--the TCP port this VirtualModem listens On.
*throws IOException when there's a problem with the serial
Or TCP port.*/
public TCPSerialVirtualModem(SerialPort serial,int speed,
int tcpport)