TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
chandra kumar
NA
15
4.4k
updatepanel with timer problem
Aug 26 2013 4:18 AM
Hi friends i am new to socket programming in asp .net c#. Currently i want to receive real time data from socket and display the data in web page using updatepanel. For this i have used a timer with update pannel. Because of using timer i think the page_load event is fired continiously and multiple instances of socket are created and it gives error" Only one instance of socket/port no permitted......".
HOW shoul i arrange the code so that socket creation will take only once.please suggest.
<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;
}
Reply
Answers (
4
)
download files(csv,zip) from web site and convert it to xls.
product key