BeardedManStudios.Network.CachedUdpClient.Send C# (CSharp) Метод

Send() публичный Метод

public Send ( byte dgram, int bytes ) : int
dgram byte
bytes int
Результат int
		public int Send(byte[] dgram, int bytes)
		{
			CheckDisposed();
			if (dgram == null)
				throw new ArgumentNullException("dgram");

			if (!active)
				throw new InvalidOperationException("Operation not allowed on " +
									 "non-connected sockets.");

			return (DoSend(dgram, bytes, null));
		}

Same methods

CachedUdpClient::Send ( byte dgram, int bytes, IPEndPoint endPoint ) : int
CachedUdpClient::Send ( byte dgram, int bytes, string hostname, int port ) : int

Usage Example

Пример #1
0
		public static void RegisterNat(ref CachedUdpClient readClient, ushort port, string proxyHost = "beardedmanstudios.com", ushort proxyPort = PROXY_PORT)
		{
			readClient = new CachedUdpClient(proxyHost, proxyPort);
			IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, 0);
			//readClient.Connect(proxyHost, proxyPort);

			try
			{
				int tryCount = 30;
				while (readClient.Available == 0)
				{
					readClient.Send(new byte[1] { 1 }, 1);
					Thread.Sleep(1000);

					if (--tryCount <= 0)
						throw new Exception("Unable to contact proxy host");
				}

				string tmp = string.Empty;
				readClient.Receive(ref endpoint, ref tmp);
			}
			catch (Exception e)
			{
				Console.WriteLine(e.ToString());
			}
		}