SharpTox.Core.Tox.GetUdpPort C# (CSharp) Method

GetUdpPort() public method

Retrieves the UDP port this instance of Tox is bound to.
public GetUdpPort ( ) : int
return int
        public int GetUdpPort()
        {
            var error = ToxErrorGetPort.Ok;
            return GetUdpPort(out error);
        }

Same methods

Tox::GetUdpPort ( ToxErrorGetPort &error ) : int

Usage Example

コード例 #1
0
ファイル: CoreSelfTests.cs プロジェクト: WELL-E/SharpTox
        public void TestToxPortBind()
        {
            var tox1 = new Tox(new ToxOptions(true, false));
            var tox2 = new Tox(new ToxOptions(true, true));

            var error = ToxErrorGetPort.Ok;
            int port = tox1.GetUdpPort(out error);
            if (error != ToxErrorGetPort.NotBound)
                Assert.Fail("Tox bound to an udp port while it's not supposed to, port: {0}", port);

            port = tox2.GetUdpPort(out error);
            if (error != ToxErrorGetPort.Ok)
                Assert.Fail("Failed to bind to an udp port");

            tox1.Dispose();
            tox2.Dispose();
        }