ex.printStackTrace();
    public void sendSlpMessage(SLPMessageHeader msg, String toAddress, int toPort,                               ServiceLocationEnumeration res) {        SLPOutputStream sos = new SLPOutputStream(new ByteArrayOutputStream());        // write message to stream        try {            socket.connect(new InetSocketAddress(toAddress, toPort), 1000);            istream = socket.getInputStream();            ostream = socket.getOutputStream();            // send message...            msg.toOutputStream(sos);            ostream.write(sos.getByteArray());            // get reply...            SLPInputStream sis = new SLPInputStream(istream);            // read function and version...            int version = sis.readByte();            int function = sis.readByte();            //System.out.println("got reply: function = " + function + ", version = " + version);            agent.handleReplyMessage(function, sis, res);            socket.close();        }catch(Exception ex) {            // handle error            ex.printStackTrace();        }    }