📄 dxclient.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: DxClient.java,v 1.9 2000/10/28 16:55:15 daniela Exp $package org.ozoneDB.DxLib.net;import java.io.*;import java.net.*;import org.ozoneDB.DxLib.*;/** * DxClient stellt ein Ende einer Socketverbindung dar, an die DxCompatibles * gesendet oder empfangen werden koennen. am anderen Ende der Verbindung * sollte entweder ein DxServer oder DxMultiServer sein. * * * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.9 $Date: 2000/10/28 16:55:15 $ */public class DxClient extends DxObject { protected Socket sock; protected ObjectInputStream in; protected ObjectOutputStream out; public DxClient() { } public DxClient( String host, int port ) throws IOException{ sock = new Socket( host, port ); out = new ObjectOutputStream( sock.getOutputStream() ); in = new ObjectInputStream( sock.getInputStream() ); onConnect(); } public DxClient( Socket s ) throws IOException{ sock = s; out = new ObjectOutputStream( sock.getOutputStream() ); in = new ObjectInputStream( sock.getInputStream() ); onConnect(); } /** * Diese Methode wird ausgefuehrt, wenn Verbindung zum Server aufgenommen * wird. Sie kann ueberschrieben werden, um ein Verbindungsprotokoll zu * implementieren. */ public void onConnect() throws IOException { } /** * Diese Methode wird analog zu onConnect() beim schliessen der Verbindung * aufgenommen. */ public void onDeconnect() throws IOException { } /** sendet ein DxCompatible in den Socket */ public synchronized void send( Object obj ) throws IOException { out.writeObject( obj ); out.flush(); out.reset(); } /** liest ein objekt aus dem socket */ public synchronized Object receive() throws IOException, ClassNotFoundException { return in.readObject(); } /** * prueft ob daten im input stream liegen */ public boolean objectAvailable() { try { return in.available() > 0; } catch (IOException e) { return false; } } public synchronized void close() throws IOException { onDeconnect(); in.close(); in = null; out.close(); out = null; sock.close(); sock = null; } public ObjectInputStream inputStream() { return in; } public ObjectOutputStream outputStream() { return out; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -