Show / Hide Table of Contents

Class ServerTcp

TCP server building on the general Server class.

Inheritance
System.Object
Server
ServerTcp
Implements
System.IDisposable
Inherited Members
Server.port
Server.DataReceived
Server.Port
Server.OnDataReceived(IPEndPoint, Byte[])
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: IMLD.MixedRealityAnalysis.Network
Assembly: Assembly-CSharp.dll
Syntax
public class ServerTcp : Server, IDisposable

Constructors

ServerTcp(Int32, Int32)

Initializes a new instance of the ServerTcp class.

Declaration
public ServerTcp(int port, int bufferSize = 65536)
Parameters
Type Name Description
System.Int32 port

The port to listen on.

System.Int32 bufferSize

The buffer size in bytes

Properties

Clients

Gets a read-only list of all currently connected clients.

Declaration
public ReadOnlyCollection<Socket> Clients { get; }
Property Value
Type Description
System.Collections.ObjectModel.ReadOnlyCollection<System.Net.Sockets.Socket>

IsListening

Gets a value indicating whether the server is currently running and listening for new connections.

Declaration
public override bool IsListening { get; }
Property Value
Type Description
System.Boolean
Overrides
Server.IsListening

NumberOfConnections

Gets the number of currently connected clients.

Declaration
public int NumberOfConnections { get; }
Property Value
Type Description
System.Int32

Methods

Dispose()

Disposes this object.

Declaration
public override void Dispose()
Overrides
Server.Dispose()

SendToClient(Socket, Byte[])

Sends data to a client.

Declaration
public void SendToClient(Socket client, byte[] data)
Parameters
Type Name Description
System.Net.Sockets.Socket client

The client to send the data to.

System.Byte[] data

The network data.

Start()

Start the server, which will try to listen for incoming data on the specified port.

Declaration
public override bool Start()
Returns
Type Description
System.Boolean

true if the server was successfully started, otherwise false.

Overrides
Server.Start()

Stop()

Stops the server if it is currently running, freeing the specified port.

Declaration
public override void Stop()
Overrides
Server.Stop()

Events

ClientConnected

Called, whenever a new client connected.

Declaration
public event SocketEventHandler ClientConnected
Event Type
Type Description
SocketEventHandler

ClientDisconnected

Called, whenever a client disconnected.

Declaration
public event SocketEventHandler ClientDisconnected
Event Type
Type Description
SocketEventHandler

Implements

System.IDisposable
In This Article
Back to top Generated by DocFX