Changeset 3509


Ignore:
Timestamp:
08/25/03 17:36:42 (19 years ago)
Author:
piso
Message:

MAKE-SOCKET

File:
1 edited

Legend:

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

    r3310 r3509  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Extensions.java,v 1.6 2003-08-10 16:28:36 piso Exp $
     5 * $Id: Extensions.java,v 1.7 2003-08-25 17:36:42 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2222package org.armedbear.lisp;
    2323
     24import java.net.Socket;
     25
    2426public final class Extensions extends Lisp
    2527{
     28    // ### special-variable-p
    2629    private static final Primitive1 SPECIAL_VARIABLE_P =
    2730        new Primitive1("special-variable-p", PACKAGE_EXT, true) {
     
    3235    };
    3336
     37    // ### charpos
    3438    private static final Primitive1 CHARPOS =
    3539        new Primitive1("charpos", PACKAGE_EXT, true) {
     
    4145        }
    4246    };
     47
     48    // ### make-socket
     49    // make-socket host port => stream
     50    private static final Primitive2 MAKE_SOCKET =
     51        new Primitive2("make-socket", PACKAGE_EXT, true) {
     52        public LispObject execute(LispObject first, LispObject second)
     53            throws LispError
     54        {
     55            String host = LispString.getValue(first);
     56            int port = Fixnum.getValue(second);
     57            try {
     58                Socket socket = new Socket(host, port);
     59                CharacterInputStream in =
     60                    new CharacterInputStream(socket.getInputStream());
     61                CharacterOutputStream out =
     62                    new CharacterOutputStream(socket.getOutputStream());
     63                return new TwoWayStream(in, out);
     64            }
     65            catch (Exception e) {
     66                throw new LispError(e.getMessage());
     67            }
     68        }
     69    };
    4370}
Note: See TracChangeset for help on using the changeset viewer.