Changeset 4123


Ignore:
Timestamp:
09/29/03 14:10:15 (20 years ago)
Author:
piso
Message:

MAKE-BINARY-SOCKET

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Extensions.java

    r4043 r4123  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Extensions.java,v 1.12 2003-09-24 22:53:30 piso Exp $
     5 * $Id: Extensions.java,v 1.13 2003-09-29 14:10:15 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    8585        }
    8686    };
     87
     88    // ### make-binary-socket
     89    // make-binary-socket host port => stream
     90    private static final Primitive2 MAKE_BINARY_SOCKET =
     91        new Primitive2("make-binary-socket", PACKAGE_EXT, true) {
     92        public LispObject execute(LispObject first, LispObject second)
     93            throws ConditionThrowable
     94        {
     95            String host = LispString.getValue(first);
     96            int port = Fixnum.getValue(second);
     97            try {
     98                Socket socket = new Socket(host, port);
     99                BinaryInputStream in =
     100                    new BinaryInputStream(socket.getInputStream());
     101                BinaryOutputStream out =
     102                    new BinaryOutputStream(socket.getOutputStream());
     103                return new TwoWayStream(in, out);
     104            }
     105            catch (Exception e) {
     106                throw new ConditionThrowable(new LispError(e.getMessage()));
     107            }
     108        }
     109    };
    87110}
Note: See TracChangeset for help on using the changeset viewer.