Cure Your Waba Woes with a Serial Socket (Continued)
(You might have a modem connected to the Palm's serial port, rather than the cradle. Though I haven't tried it, I'm confident that the Web example would dial out and work fine with a modem. I haven't tried it because I don't have a modem connected to my Palm. I have a T1 Internet connection on my laptop, to which my Palm is connected.)
The solution? Well, I ended up with two solutions to the problem. The first is the "messy" solution. It's messy because I wrote it myself. It's cheaper than the other solution, but its main advantage is that, with a little work, it could be extended to platforms. I call it a Serial Port Socket—sort of a poor-man's implementation of a point-to-point protocol.
The Messy Way
The architecture of my Serial Port Socket system uses what amounts to a client/server structure (see Figure 1). The client side depends on a class called spSocket (serial port Socket), which mimics the behavior of a Socket object to the application. The spSocket object talks through the serial port to an application running on the desktop that implements the pspSocket (proxy for serial port Socket) class. This target application is also written using the Waba classes. (The pspSocket class is accompanied by another class that, as you'll see, forms the outer loop for handling incoming requests. But because most of the work is done by pspSocket, I'll say that the desktop proxy implements that class.)
Simply put, requests that would ordinarily go to the Socket object go to the spSocket object, which stuffs them into a packet and sends them by serial port to the pspSocket application. The pspSocket application runs on a host (that does have Internet access), grabs the requests coming in from the client, passes them to a real Socket object, and sends the responses back.
The spSocket class provides all the important methods of Waba's Socket class:
- Constructor: The constructor not only instantiates a spSocket object, but also establishes a connection to the target URL and port.
- isOpen(): This method returns a boolean indicating whether the port was opened successfully.
- readBytes(): This method reads a byte array from the socket.
- writeBytes(): This method writes a byte array to the socket.
- close(): This method closes the spSocket. It closes not only the socket on the proxy side, but the serial port connection as well.
Back to top
|