< Summary

Information
Class: Ice.Internal.TcpTransceiver
Assembly: Ice
File(s): /home/runner/work/ice/ice/csharp/src/Ice/Internal/TcpTransceiver.cs
Tag: 71_18251537082
Line coverage
94%
Covered lines: 33
Uncovered lines: 2
Coverable lines: 35
Total lines: 91
Line coverage: 94.2%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage
89%
Covered methods: 17
Total methods: 19
Method coverage: 89.4%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
fd()100%11100%
initialize(...)100%11100%
closing(...)100%11100%
close()100%11100%
bind()100%210%
destroy()100%11100%
write(...)100%11100%
read(...)100%11100%
startRead(...)100%11100%
finishRead(...)100%11100%
startWrite(...)100%11100%
finishWrite(...)100%11100%
protocol()100%11100%
getInfo(...)100%22100%
checkSendSize(...)100%11100%
setBufferSize(...)100%11100%
ToString()100%11100%
toDetailedString()100%210%
.ctor(...)100%11100%

File(s)

/home/runner/work/ice/ice/csharp/src/Ice/Internal/TcpTransceiver.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Diagnostics;
 4using System.Net;
 5using System.Net.Sockets;
 6
 7namespace Ice.Internal;
 8
 9internal sealed class TcpTransceiver : Transceiver
 10{
 111    public Socket fd() => _stream.fd();
 12
 13    public int initialize(Buffer readBuffer, Buffer writeBuffer, ref bool hasMoreData) =>
 114        _stream.connect(readBuffer, writeBuffer, ref hasMoreData);
 15
 16    public int closing(bool initiator, Ice.LocalException ex) =>
 17        // If we are initiating the connection closure, wait for the peer
 18        // to close the TCP/IP connection. Otherwise, close immediately.
 119        initiator ? SocketOperation.Read : SocketOperation.None;
 20
 121    public void close() => _stream.close();
 22
 23    public EndpointI bind()
 24    {
 25        Debug.Assert(false);
 026        return null;
 27    }
 28
 129    public void destroy() => _stream.destroy();
 30
 131    public int write(Buffer buf) => _stream.write(buf);
 32
 133    public int read(Buffer buf, ref bool hasMoreData) => _stream.read(buf);
 34
 135    public bool startRead(Buffer buf, AsyncCallback callback, object state) => _stream.startRead(buf, callback, state);
 36
 137    public void finishRead(Buffer buf) => _stream.finishRead(buf);
 38
 39    public bool startWrite(Buffer buf, AsyncCallback callback, object state, out bool messageWritten) =>
 140        _stream.startWrite(buf, callback, state, out messageWritten);
 41
 142    public void finishWrite(Buffer buf) => _stream.finishWrite(buf);
 43
 144    public string protocol() => _instance.protocol();
 45
 46    public ConnectionInfo getInfo(bool incoming, string adapterName, string connectionId)
 47    {
 148        if (_stream.fd() is null)
 49        {
 150            return new TCPConnectionInfo(incoming, adapterName, connectionId);
 51        }
 52        else
 53        {
 154            EndPoint localEndpoint = Network.getLocalAddress(_stream.fd());
 155            EndPoint remoteEndpoint = Network.getRemoteAddress(_stream.fd());
 56
 157            return new TCPConnectionInfo(
 158                incoming,
 159                adapterName,
 160                connectionId,
 161                Network.endpointAddressToString(localEndpoint),
 162                Network.endpointPort(localEndpoint),
 163                Network.endpointAddressToString(remoteEndpoint),
 164                Network.endpointPort(remoteEndpoint),
 165                Network.getRecvBufferSize(_stream.fd()),
 166                Network.getSendBufferSize(_stream.fd()));
 67        }
 68    }
 69
 70    public void checkSendSize(Buffer buf)
 71    {
 172    }
 73
 174    public void setBufferSize(int rcvSize, int sndSize) => _stream.setBufferSize(rcvSize, sndSize);
 75
 176    public override string ToString() => _stream.ToString();
 77
 078    public string toDetailedString() => ToString();
 79
 80    //
 81    // Only for use by TcpConnector, TcpAcceptor
 82    //
 183    internal TcpTransceiver(ProtocolInstance instance, StreamSocket stream)
 84    {
 185        _instance = instance;
 186        _stream = stream;
 187    }
 88
 89    private readonly ProtocolInstance _instance;
 90    private readonly StreamSocket _stream;
 91}