State Management :: Keep Socket Connection Open?
May 26, 2010
I wrote a small socket client application talking to my asp.net server application.
On the asp.net side, I created a IHttpHandler. I want to send data back and forth on one HTTP request.
I tried the following code which run an infinite loop inside function ProcessRequest(). The client side opens a socket connection and send HTTP POST request.
I am not sure how asp.net work. In HTTP POST I have to specify Content-Length, I tried a small value, like 20, then asp.net handler can only get 20 bytes in the inputstream. I tried to use 4096000 bytes(close to the maximum IIS allowed), then the inputstream cannot get anything, it seems IIS is waiting for all data(4096000) to come from client side before it gives the handler a chance to read from the socket.
public class DeviceDataHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
try
{
Stream inputstream = context.Request.InputStream;
Stream outputstream = context.Response.OutputStream;
/loop forever until exception is thrown
while (true)
{
ProcessData(inputstream, outputstream);
}
}
catch (Exception ex)
{
ZenLog.logError("DeviceConnector exception: " + ex.Message);
}
}
public bool IsReusable
{
get
{
return true;
}
}
}
View 1 Replies
Similar Messages:
Sep 13, 2010
I'm using Visual Studio 2008, and my database is SQL Server 2000.
I want to add a connection to the Server Explorer in VS. The Data source is Microsoft SQL Server (SqlClient). After entering in all my information and I click Test Connection, it is successful.
But when I click OK, I get the error:
Unable to add data connection. ExecuteScalar requires an open and available connection. The connection's current state is closed.
View 3 Replies
Jul 28, 2010
Iam trying to make a socket connection and am facing with the following error.
Socket tempSocket =new
Socket(ipe.AddressFamily,
SocketType.Stream,
ProtocolType.Tcp);
The tempSocket is connected to the particular IP and tempSocket.Connected is giving me value as True. But the property MultiCastLoopBack property is giving me the following error with error code 10042.
"An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call."
So is there any problem with the IP or Tcp is not supported with Stream as SocketType?
View 3 Replies
Oct 22, 2010
Am using socket connection to send and receive values. The following code is used to receive response.
[Code]....
In the above code, am facing a prob in skt.Available. If i dont give the thread.sleep, it is not repeating the while loop and it exits after onetime. And if i dont give skt.Available line, sometimes it throws socket Exception. I do not want to use thread.sleep. Does anyone knows why this is happening and how can i resolve this?
View 4 Replies
Feb 7, 2011
Is it possible to assign the connection string in session variable and is it the good way to declare in session.
provide the sytax for accessing connection string from session variable
View 7 Replies
Apr 14, 2013
In my asp.net +vb+access web i have made a login page and the code is as under
Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:webauth.mdb"
Dim con As OleDbConnection = New OleDbConnection(connectString)
con.Open()
Dim cmd As New OleDbCommand("select * from Users where userid =@userid and Password=@password", con)
cmd.Parameters.AddWithValue("@userid", txtUserName.Text)
[Code] ....
I am getting error The connection was not closed. The connection's current state is open.
View 1 Replies
May 7, 2015
I would like to ask why I encounter this error when multiple user accessing in my online page.
Here is the error message.
Execute Reader requires an open and available Connection's current state is connecting.
View 1 Replies
Dec 31, 2010
This last week I had an issue about refreshing all open sessions on an asp.net web site. The scenario it's like this:
It's a LAN application with different roles (let's say "Role A" and "Role B") and a database of SQL server.
Any "Role A" user can click a button and start something like a survey (defines a query and the possible options).
Then, any "Role B" user have to answer that survey (just once).
Here comes my problem...if I am a "Role B" user, and I have the "AnswerToSurvey.aspx" page open...how it can automatically update or refresh after the "Role A" user inserted the survey? I mean, I know that if I press F5 I will achieve it, or even using asp:Timer or javascript timer, but any of them are precise.
Any suggest? I've tried using Global.asax Application_BeginRequest and so, but no lucky. Is there any effective way to notifiy a user that something has changed? I'm not looking for a "chat like" system, just notify any "Role B" user about the change.
View 3 Replies
Jul 28, 2010
I have a site that I am trying to extend how long a session stays open even though the user is inactive. I have this set in my web.config
<sessionState mode="InProc" timeout="720" />
And this is set it IIS
Time-out (in minutes):
720
But it is still timing out after like 15 minutes.
View 6 Replies
Sep 20, 2010
I have this code (just for example):
[Code]....
The Code-behind file looks like that:
[Code]....
So, when i use
[Code]....
SelectedIndexChanged event doesn't fire for the first item of the DropDownList. For any other item SelectedIndexChanged fires, but not for the first one.Could someone, please, explain what kind of magic is it?(I use Visual Studio 2008)
View 2 Replies
Sep 20, 2010
i create a web site using frame and child when session i s out i require Login page open in browser not opend in frmaehow to set Session out open login page
View 1 Replies
Sep 17, 2010
how to clear cokkies when my website open
View 3 Replies
Jun 10, 2010
Existing applications works fine with IE 6 and 7, the problem occurs only with IE 8. A new session is created everytime a window.open is used to open a new asp page. This does not happen in IE 6 or 7.
View 2 Replies
Sep 3, 2010
I only made 1 other dynamic page before, without users. I do remember I setup a read-only user to the database and that was the user used in the connection string, simple.
In managing multiple users, does asp.net's membership & roles automatically switch up the databases connection string upon login? Do you setup hypothetical "groups" of user access permissions in your database (mysql) then associate that user to that group in membership & roles?
I'm just looking for a general idea of what to expect before I start reading.
View 2 Replies
Nov 3, 2010
I am working a survey project. There are about 30 questions. I created two pages to sore these questions.
View 2 Replies
Jul 28, 2010
By default when the Session ends then the End-User should be directs to the login page and logs in again. Is there any way to open the login page in a new page rather than opening it in the same page(upon Session time out)?
View 8 Replies
Oct 1, 2010
when my session timed out than
error page is
[URL]
how to open Login page in Separate window
View 2 Replies
Sep 10, 2010
We got a problem that Sessions got mixed up when open multiple tab in a single application. We could change the code that do not use session variable in a that level, but a tons of page need to be modified. We need to find a quick fix for this problem. Is any thing we can do in code level to prevent user open multiple tab in a single application? O any thing we can do to keep its own session for a single tab?
View 6 Replies
Jun 5, 2010
I previously used a datasource and a connection string to connect to my database on sql server and all orked fine. The connection string was saved in my web.config file and is: ....
View 1 Replies
Feb 25, 2011
when we go for client and server side state management in asp.net
View 2 Replies
Apr 7, 2010
In my DAL i have more than 100 methods/Function, each and every method am opening the sqlconnection and closing the connection, this is taking too much of time to establish the connection at every time. So what i expect is one common class will create the SqlConnection that will check if the connection is Broken or Closed then create the connection again else return the connection, how to do this(Also i would like to apply ConnectionPooling).
View 7 Replies
May 29, 2010
I am doing a POC of making my website run faster. Currently it stores huge object data in Session while passing information from one page to another. What I was thinking is to use shared methods and properties instead of session. It works, but wanted tocheck if this is an optimum way to do it. Below is the code that does not use session but still pass object data from one page to another:
[code]...
View 1 Replies
Nov 18, 2010
i have a form on page1.aspx with several controls (textbox, dropdownlist, etc).on Page1 PageLoad event i load data from database and performe databinding.From Page1 a user can, by clicking a specific button, move to Page2.aspx to insert some details and, after saving details, he returns to page1.
if save changes are made on control on page1 before save them to db, obviously, these are lost on return from page2 (because are reloaded on pageload from db).How can i save control status between pages round trip?
View 3 Replies
Aug 16, 2010
i need to know the full concepts state manegemnt in asp.net,..in which site i will get the correct concept for state management....
View 4 Replies
Feb 10, 2010
In code below, when I have more than one DIV open and I choose to sort one of the GridViews, all the other Open Div's will close automatically. How can i keep the DIV's in the state they are in when I sort any GridView?
[Code]....
View 3 Replies