Beispiel #1
0
        static int _m_Create(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                System.Net.IPEndPoint gen_to_be_invoked = (System.Net.IPEndPoint)translator.FastGetCSObj(L, 1);



                {
                    System.Net.SocketAddress _socketAddress = (System.Net.SocketAddress)translator.GetObject(L, 2, typeof(System.Net.SocketAddress));

                    System.Net.EndPoint gen_ret = gen_to_be_invoked.Create(
                        _socketAddress);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            int Port = 5150;

            try
            {
                System.Net.IPAddress IPAddress;

                IPAddress = System.Net.IPAddress.Any;

                System.Net.IPEndPoint LocalEP = new System.Net.IPEndPoint(IPAddress, Port);

                System.Net.Sockets.Socket ReceivingSocket = new System.Net.Sockets.Socket(
                    System.Net.Sockets.AddressFamily.InterNetwork,
                    System.Net.Sockets.SocketType.Dgram,
                    System.Net.Sockets.ProtocolType.Udp);

                ReceivingSocket.Bind(LocalEP);

                System.Console.WriteLine("Waiting for data...");

                byte [] buffer = new byte[1024];

                System.Net.IPAddress  RemoteIPAddress  = System.Net.IPAddress.Any;
                System.Net.IPEndPoint RemoteIPEndPoint = new System.Net.IPEndPoint(
                    RemoteIPAddress, 0);
                System.Net.SocketAddress RemoteAddress = new System.Net.SocketAddress(
                    System.Net.Sockets.AddressFamily.InterNetwork);
                System.Net.EndPoint RefRemoteEP = RemoteIPEndPoint.Create(RemoteAddress);

                int BytesReceived = ReceivingSocket.ReceiveFrom(buffer, ref RefRemoteEP);

                System.Console.WriteLine("Successfully received " +
                                         BytesReceived.ToString() + " byte(s) from " +
                                         RefRemoteEP.ToString());

                ReceivingSocket.Close();
            }

            catch (System.Net.Sockets.SocketException err)
            {
                Console.WriteLine("Error: " + err.Message);
            }
        }