Source Code Cross Referenced for DxClient.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » DxLib » net » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » Ozone 1.1 » org.ozoneDB.DxLib.net 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // You can redistribute this software and/or modify it under the terms of
002:        // the Ozone Library License version 1 published by ozone-db.org.
003:        //
004:        // The original code and portions created by SMB are
005:        // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006:        //
007:        // $Id: DxClient.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
008:
009:        package org.ozoneDB.DxLib.net;
010:
011:        import java.io.*;
012:        import java.net.*;
013:        import org.ozoneDB.DxLib.*;
014:
015:        /**
016:         * DxClient stellt ein Ende einer Socketverbindung dar, an die DxCompatibles
017:         * gesendet oder empfangen werden koennen. am anderen Ende der Verbindung
018:         * sollte entweder ein DxServer oder DxMultiServer sein.
019:         * 
020:         * 
021:         * @author <a href="http://www.softwarebuero.de/">SMB</a>
022:         * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
023:         */
024:        public class DxClient extends DxObject {
025:
026:            /**
027:             * The size of the stream buffers. This should be smaller than the MTU of
028:             * the connections, which for Ethernet is 1500. (is this right?)
029:             */
030:            protected final static int buffSize = 1024;
031:
032:            protected Socket sock;
033:
034:            protected ObjectInputStream in;
035:
036:            protected ObjectOutputStream out;
037:
038:            public DxClient() {
039:            }
040:
041:            public DxClient(String host, int port) throws IOException {
042:                sock = new Socket(host, port);
043:                init();
044:
045:                onConnect();
046:            }
047:
048:            public DxClient(Socket s) throws IOException {
049:                sock = s;
050:                init();
051:
052:                onConnect();
053:            }
054:
055:            protected void init() throws IOException {
056:                // this buffer size values seems to work for a localhost connections
057:                // which is the fastest possible case; we rely on OS setting however
058:                // since the kernel may better know what is a good buffer size; with
059:                // many connections this may lead to memory issues
060:
061:                //        sock.setSendBufferSize( buffSize * 10 );
062:                //        sock.setReceiveBufferSize( buffSize * 10 );
063:                //        System.out.println( sock.getSendBufferSize() + ", " + sock.getReceiveBufferSize() );
064:
065:                out = new ObjectOutputStream(new BufferedOutputStream(sock
066:                        .getOutputStream(), buffSize));
067:                // send the header data
068:                out.flush();
069:
070:                in = new ObjectInputStream(new BufferedInputStream(sock
071:                        .getInputStream(), buffSize));
072:            }
073:
074:            /**
075:             * Diese Methode wird ausgefuehrt, wenn Verbindung zum Server aufgenommen
076:             * wird. Sie kann ueberschrieben werden, um ein Verbindungsprotokoll zu
077:             * implementieren.
078:             */
079:            public void onConnect() throws IOException {
080:            }
081:
082:            /**
083:             * Diese Methode wird analog zu onConnect() beim schliessen der Verbindung
084:             * aufgenommen.
085:             */
086:            public void onDeconnect() throws IOException {
087:            }
088:
089:            public void send(Object obj) throws IOException {
090:                try {
091:                    out.writeObject(obj);
092:                } finally {
093:                    out.flush();
094:                    out.reset();
095:                }
096:            }
097:
098:            public Object receive() throws IOException, ClassNotFoundException {
099:                return in.readObject();
100:            }
101:
102:            /**
103:             * prueft ob daten im input stream liegen
104:             */
105:            public boolean objectAvailable() {
106:                try {
107:                    return in.available() > 0;
108:                } catch (IOException e) {
109:                    return false;
110:                }
111:            }
112:
113:            public synchronized void close() throws IOException {
114:                onDeconnect();
115:                //        in.close();
116:                in = null;
117:                //        out.flush();
118:                //        out.close();
119:                out = null;
120:                sock.close();
121:                sock = null;
122:            }
123:
124:            public ObjectInputStream inputStream() {
125:                return in;
126:            }
127:
128:            public ObjectOutputStream outputStream() {
129:                return out;
130:            }
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.