Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Real time web application in asp .net c#

$
0
0

Hi friend i am new to socket programming using asp .net c#. Currently i am  working on apllication which will receive real time string through multicast socket and display in web form. The data update rate is 1000ms. I have tried uding the updatepanel and timer in c# AJAX controls. But the problem is that on page_load event when i create the socket it gets executed multiple times because of timer. So i get error" Only one instance of socket/port no is permitted ....". How should i use the code so that socket ceation part will execute only once. Please suggest.

The code is as given below. Thanking you all in advance



<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
<br />
            <asp:Timer ID="Timer1" runat="server" Interval="1000">
            </asp:Timer>
            <br />
            <br />
            <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="50pt"
             Text="Label"></asp:Label>
            <br />
            <br />
            <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="50pt"
                Text="Label"></asp:Label>
            <br />
          
            <br />
           
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
    </asp:UpdatePanel>




code behind is like this


  protected void Page_Load(object sender, EventArgs e)
    {
      Label1.Text = System.DateTime.Now.ToLongTimeString();
         

    // socket creation part

      IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 4321);
      s.Bind(ipep);
      IPAddress ip = IPAddress.Parse("226.1.1.1");
      s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership,
      new MulticastOption(ip, IPAddress.Any));

     


    // data receive and display
      DataSize = s.Receive(databuffer);
      raw = System.Text.Encoding.ASCII.GetString(databuffer);
      Label2.Text = raw;

    }


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>