ICE 3.4.2
[php5-ice-freebsdport.git] / cs / test / Ice / background / Transceiver.cs
blobee9b6bbb60bb4ce77acfabb5afd0f10b066c11b8
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 using System;
11 using System.Net.Sockets;
13 internal class Transceiver : IceInternal.Transceiver
15 public int initialize()
17 _configuration.checkInitializeException();
18 if(!_initialized)
20 int s = _transceiver.initialize();
21 if(s != IceInternal.SocketOperation.None)
23 return s;
25 _initialized = true;
27 return IceInternal.SocketOperation.None;
30 public void close()
32 _transceiver.close();
35 public bool write(IceInternal.Buffer buf)
37 if(!_initialized)
39 throw new Ice.SocketException();
42 if(!_configuration.writeReady())
44 return false;
47 _configuration.checkWriteException();
48 return _transceiver.write(buf);
51 public bool read(IceInternal.Buffer buf)
53 if(!_initialized)
55 throw new Ice.SocketException();
58 if(!_configuration.readReady())
60 return false;
63 _configuration.checkReadException();
64 return _transceiver.read(buf);
67 public bool startRead(IceInternal.Buffer buf, AsyncCallback callback, object state)
69 if(_configuration.readReady())
71 _configuration.checkReadException(); // Only raise if we're configured to read now.
73 return _transceiver.startRead(buf, callback, state);
76 public void finishRead(IceInternal.Buffer buf)
78 _configuration.checkReadException();
79 _transceiver.finishRead(buf);
82 public bool startWrite(IceInternal.Buffer buf, AsyncCallback callback, object state, out bool completed)
84 _configuration.checkWriteException();
85 return _transceiver.startWrite(buf, callback, state, out completed);
88 public void finishWrite(IceInternal.Buffer buf)
90 _configuration.checkWriteException();
91 _transceiver.finishWrite(buf);
94 public string type()
96 return "test-" + _transceiver.type();
99 public Ice.ConnectionInfo getInfo()
101 return _transceiver.getInfo();
104 public override string ToString()
106 return _transceiver.ToString();
109 public void checkSendSize(IceInternal.Buffer buf, int messageSizeMax)
111 _transceiver.checkSendSize(buf, messageSizeMax);
115 // Only for use by Connector, Acceptor
117 internal Transceiver(IceInternal.Transceiver transceiver)
119 _transceiver = transceiver;
120 _configuration = Configuration.getInstance();
123 private IceInternal.Transceiver _transceiver;
124 private Configuration _configuration;
125 private bool _initialized = false;