- Home /
Question by
Slight0 · Aug 23, 2015 at 12:12 AM ·
networkingdocumentation
What are the possible error codes for NetworkTransport.Send?
The documentation does not mention what the possible error codes are for the NetworkTransport.Send method. (As well as other methods in the class)
Defined like so
public static bool Send(int hostId, int connectionId, int channelId, byte[] buffer, int size, out byte error);
What are the possible error codes it could output?
Comment
Best Answer
Answer by Slight0 · Aug 23, 2015 at 03:06 AM
After some searching through the decompiled classes of the networking dll it seems the NetworkError enumeration directly corresponds with the returned error codes of the transport layer functions.
// Everything good so far.
Ok = 0,
//
// Host doesn't exist.
WrongHost = 1,
//
// Connection doesn't exist.
WrongConnection = 2,
//
// Channel doesn't exist.
WrongChannel = 3,
//
// No internal resources ro acomplish request.
NoResources = 4,
//
// Obsolete.
BadMessage = 5,
//
// Timeout happened.
Timeout = 6,
//
// Sending message too long to fit internal buffers, or user doesn't present
// buffer with length enouf to contain receiving message.
MessageToLong = 7,
//
// Operation is not supported.
WrongOperation = 8,
//
// Different version of protocol on ends of connection.
VersionMismatch = 9,
//
// Two ends of connection have different agreement about channels, channels
// qos and network parameters.
CRCMismatch = 10,
//
// The address supplied to connect to was invalid or could not be resolved.
DNSFailure = 11,
Answer by seanr · Aug 26, 2015 at 07:40 PM
http://docs.unity3d.com/ScriptReference/Networking.NetworkError.html
Answer by ZalmakiZ · Oct 18, 2015 at 10:53 AM
you can easy cast the error byte to the Error enum types to get a string with the error name example:
byte lastError;
NetworkTransport.Send(hostID, clientID, channel, data, offset, out lastError);
if ((NetworkError)lastError != NetworkError.Ok)
{
Debug.Log("Message send error: " + (NetworkError)lastError);
}