/[classpath]/classpath/gnu/java/rmi/server/UnicastConnection.java
ViewVC logotype

Diff of /classpath/gnu/java/rmi/server/UnicastConnection.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mark, Tue Jan 22 22:26:57 2002 UTC revision 1.3 by cbj, Thu Mar 21 05:40:11 2002 UTC
# Line 44  import java.io.DataInputStream; Line 44  import java.io.DataInputStream;
44  import java.io.DataOutputStream;  import java.io.DataOutputStream;
45  import java.io.ObjectInputStream;  import java.io.ObjectInputStream;
46  import java.io.ObjectOutputStream;  import java.io.ObjectOutputStream;
47    import java.io.BufferedInputStream;
48    import java.io.BufferedOutputStream;
49  import java.io.ObjectOutput;  import java.io.ObjectOutput;
50  import java.io.ObjectInput;  import java.io.ObjectInput;
51  import java.io.IOException;  import java.io.IOException;
# Line 65  UnicastConnection(UnicastConnectionManag Line 67  UnicastConnection(UnicastConnectionManag
67  }  }
68    
69  void acceptConnection() throws IOException {  void acceptConnection() throws IOException {
70  //System.out.println("Accepting connection on " + lport);  //System.out.println("Accepting connection on " + sock);
71          din = new DataInputStream(sock.getInputStream());      //Use BufferedXXXStream would be more efficient
72          dout = new DataOutputStream(sock.getOutputStream());          din = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
73            dout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
74    
75          int sig = din.readInt();          int sig = din.readInt();
76          if (sig != PROTOCOL_HEADER) {          if (sig != PROTOCOL_HEADER) {
# Line 85  void acceptConnection() throws IOExcepti Line 88  void acceptConnection() throws IOExcepti
88                  // Send my hostname and port                  // Send my hostname and port
89                  dout.writeUTF(manager.serverName);                  dout.writeUTF(manager.serverName);
90                  dout.writeInt(manager.serverPort);                  dout.writeInt(manager.serverPort);
91                    dout.flush();
92    
93                  // Read their hostname and port                  // Read their hostname and port
94                  String rhost = din.readUTF();                  String rhost = din.readUTF();
# Line 94  void acceptConnection() throws IOExcepti Line 98  void acceptConnection() throws IOExcepti
98  }  }
99    
100  void makeConnection(int protocol) throws IOException {  void makeConnection(int protocol) throws IOException {
101          dout = new DataOutputStream(sock.getOutputStream());      //Use BufferedXXXStream would be more efficient
102          din = new DataInputStream(sock.getInputStream());          din = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
103            dout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
104    
105          // Send header          // Send header
106          dout.writeInt(PROTOCOL_HEADER);          dout.writeInt(PROTOCOL_HEADER);
107          dout.writeShort(PROTOCOL_VERSION);          dout.writeShort(PROTOCOL_VERSION);
108          dout.writeByte(protocol);          dout.writeByte(protocol);
109          dout.flush();      dout.flush();
110        
111          if (protocol != SINGLE_OP_PROTOCOL) {          if (protocol != SINGLE_OP_PROTOCOL) {
112                  // Get back ack.                  // Get back ack.
113                  int ack = din.readUnsignedByte();                  int ack = din.readUnsignedByte();
# Line 117  void makeConnection(int protocol) throws Line 122  void makeConnection(int protocol) throws
122                  // Send them my endpoint                  // Send them my endpoint
123                  dout.writeUTF(manager.serverName);                  dout.writeUTF(manager.serverName);
124                  dout.writeInt(manager.serverPort);                  dout.writeInt(manager.serverPort);
125                    dout.flush();
126          }          }
127          // Okay, ready to roll ...          // Okay, ready to roll ...
128  }  }
# Line 144  ObjectOutputStream getObjectOutputStream Line 150  ObjectOutputStream getObjectOutputStream
150  }  }
151    
152  void disconnect() {  void disconnect() {
         oin = null;  
         oout = null;  
153          try {          try {
154                  sock.close();              if(oout != null)
155                    oout.close();
156          }          }
157          catch (IOException _) {          catch (IOException _) {
158          }      }
159    
160            oin = null;
161        oout = null;
162          din = null;          din = null;
163          dout = null;          dout = null;
164          sock = null;          sock = null;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26