Interface INetworkDriver
The NetworkDriver interface is the main entry point for the transport.
The Driver is similar to a UDP socket which can handle many connections.
Syntax
public interface INetworkDriver : IDisposable
Properties
IsCreated
Declaration
Property Value
Listening
Declaration
Property Value
Methods
Accept()
Accept a pending connection attempt and get the established connection.
This should be called until it returns an invalid connection to make sure
all connections are accepted.
Declaration
NetworkConnection Accept()
Returns
Type |
Description |
NetworkConnection |
Returns a newly created NetworkConnection if it was Successful and a default(NetworkConnection)
if there where no more new NetworkConnections to accept.
|
Bind(NetworkEndPoint)
Bind the NetworkDriver to a port locally. This must be called before
the socket can listen for incoming connections.
Declaration
int Bind(NetworkEndPoint endpoint)
Parameters
Returns
Type |
Description |
Int32 |
Returns 0 on Success.
|
Connect(NetworkEndPoint)
Establish a new connection to a server with a specific address and port.
Declaration
NetworkConnection Connect(NetworkEndPoint endpoint)
Parameters
Type |
Name |
Description |
NetworkEndPoint |
endpoint |
A valid NetworkEndPoint, can be implicitly cast using an System.Net.IPEndPoint
|
Returns
CreatePipeline(Type[])
Create a pipeline which can be used to process data packets sent and received by the transport package.
The pipelines must be created in the same order on the client and server since they are identified by
an index which is assigned on creation.
All pipelines must be created before the first connection is established.
Declaration
NetworkPipeline CreatePipeline(params Type[] stages)
Parameters
Type |
Name |
Description |
Type[] |
stages |
|
Returns
Disconnect(NetworkConnection)
Disconnect an existing connection.
Declaration
int Disconnect(NetworkConnection con)
Parameters
Returns
Type |
Description |
Int32 |
Returns 0 on Success.
|
GetConnectionState(NetworkConnection)
Get the state of an existing connection. If called with an invalid connection the call will return the Destroyed state.
Declaration
NetworkConnection.State GetConnectionState(NetworkConnection con)
Parameters
Returns
Listen()
Enable listening for incoming connections on this driver. Before calling this
all connection attempts will be rejected.
Declaration
Returns
Type |
Description |
Int32 |
Returns 0 on Success.
|
LocalEndPoint()
Declaration
NetworkEndPoint LocalEndPoint()
Returns
PopEvent(out NetworkConnection, out DataStreamReader)
Receive an event for any connection.
Declaration
NetworkEvent.Type PopEvent(out NetworkConnection con, out DataStreamReader bs)
Parameters
Returns
PopEventForConnection(NetworkConnection, out DataStreamReader)
Receive an event for a specific connection. Should be called until it returns Empty, even if the socket is disconnected.
Declaration
NetworkEvent.Type PopEventForConnection(NetworkConnection con, out DataStreamReader bs)
Parameters
Returns
RemoteEndPoint(NetworkConnection)
Declaration
NetworkEndPoint RemoteEndPoint(NetworkConnection con)
Parameters
Returns
ScheduleUpdate(JobHandle)
Schedule a job to update the state of the NetworkDriver, read messages and events from the underlying
network interface and populate the event queues to allow reading from connections concurrently.
Declaration
JobHandle ScheduleUpdate(JobHandle dep = null)
Parameters
Type |
Name |
Description |
JobHandle |
dep |
Used to chain dependencies for jobs.
|
Returns
Type |
Description |
JobHandle |
A for the ScheduleUpdate Job.
|
Send(NetworkPipeline, NetworkConnection, IntPtr, Int32)
Send a message to the specific connection.
Declaration
int Send(NetworkPipeline pipe, NetworkConnection con, IntPtr data, int len)
Parameters
Returns
Send(NetworkPipeline, NetworkConnection, DataStreamWriter)
Send a message to the specific connection.
Declaration
int Send(NetworkPipeline pipe, NetworkConnection con, DataStreamWriter strm)
Parameters
Returns
Type |
Description |
Int32 |
Returns the size in bytes that was sent, -1 on failure.
|
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.