Ejemplo n.º 1
0
    public void send_serverinfo(string ip, int port)
    {
        UdpClient  udpClient  = new UdpClient();
        IPEndPoint iPEndPoint = new IPEndPoint(IPAddress.Parse(ip), port);

        UDPClient.UdpState udpState = new UDPClient.UdpState();
        udpState.e = iPEndPoint;
        udpState.u = udpClient;
        try
        {
            NET.BEGIN_WRITE();
            NET.WRITE_BYTE(244);
            NET.WRITE_BYTE(0);
            NET.WRITE_BYTE(0);
            NET.WRITE_BYTE(0);
            NET.WRITE_FLOAT(Time.time);
            NET.END_WRITE();
            udpClient.Send(NET.WRITE_DATA(), NET.WRITE_LEN(), iPEndPoint);
        }
        catch
        {
            UnityEngine.Debug.LogWarning("[udp] send error");
        }
        udpClient.BeginReceive(new AsyncCallback(UDPClient.ReceiveCallback), udpState);
        base.StartCoroutine(this.forceclose(udpClient));
    }