Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package virtualModem;
- import ithakimodem.Modem;
- /*
- *
- * Δίκτυα Υπολογιστών I
- *
- * Experimental Virtual Lab
- *
- * Java virtual modem communications seed code
- *
- */
- public class virtualModem {
- public static void main(String[] param) {
- int k;
- Modem modem;
- modem=new Modem();
- modem.setSpeed(1000);
- modem.setTimeout(2000);
- modem.open("ithaki");
- byte[] req = "E3521\r".getBytes();
- ;
- for (;;) {
- try {
- modem.write(req);
- k=modem.read();
- if (k==-1) break;
- System.out.print((char)k);
- } catch (Exception x) {
- break;
- }
- }
- modem.close();
- }
- }
- // NOTE : Break endless loop by catching sequence "\r\n\n\n".
- // NOTE : Stop program execution when "NO CARRIER" is detected.
- // NOTE : A time-out option will enhance program behavior.
- // NOTE : Continue with further Java code.
- // NOTE : Enjoy :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement