This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Hi, i want to open a connection when i log into my application and the connection needs to be persistant till i log out or until i forced to close the connection.so that i can able to send and receive data without opening the connection everytime Kindly post me regarding this query Regards sangeeth
A persistent connection to what? A web server? Web servers don't work that way.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Aug 04, 2001
Hi Tim Holloway , Thanks for your reply ... No , i donot want to have a connection with webserver. i want to make a connection using socket(tcp /ip communication). Please see the following for the client side code Client ********* //open the connection InetAddress hostAddr = InetAddress.getByName(IPADDRESS); int hostPort = PORT; Socket soc = new Socket(hostAddr,hostPort); //Send value to server PrintWriter theWriter = new PrintWriter(soc.getOutputStream(),true); theWriter.println("Hi from client "); //receive the data from the server String input = "NoValue"; BufferedReader theReader = new BufferedReader(new InputStreamReader(soc.getInputStream())); while((input = theReader.readLine()) != null) System.out.println("SERVER REPLIED : " + input + "\n"); //close the socket ,I/O stream theReader.close(); theWriter.close(); soc.close(); ***** end of the part of the code ***** now i want to split the above stpes into separate methods for example, open close send receive so from another class ie at the start point- may be login time) of the applicaion i can call open method to establish the connection and i can call send and receive method for many time s to send and receive the data and in the end point(may be loged out ) of the application i can call close method to close the socket. Hope now you can have an idea about what i am asking.... i want to save the time for open and close the socket for each and every request and response. Thanks & Regards, Sangeeth
OK, but you never did say what kind of server you wanted to talk to. Just some app you wrote using sockets? The sandbox rules apply to socket I/O just as they do to higher-level network I/O, so bear that in mind. Probably what you want to do is have the applet open the socket, then manage the network connection with threads, so that the applet's UI doesn't get bogged down (depends on what all is supposed to be happening at the time). Excluding the extra security, there's no magic to it. Well, almost none. When people flip around web pages, crash their browsers, etc. that can make it harder to detect when they've "logged out", but that's just something you have to allow for - supply a "disconnect" button and/or log off in the applet's "stop" method.
Joined: Aug 04, 2001
Hi Tim Holloway, In our application the server side coding are in "c" and the client side is in "java".so all the session handling things will be take care by "c".Our "c" team is working on it so that from java i can able to have one time connection and hope the issue will be solved. Thanks , Sangeeth
Interesting. Have you considered CORBA? It might be simpler for what you want. I do need to make the standard "It probably won't work on the Internet disclaimer" - CORBA tcp/ip ports will probably be blocked by most firewalls. Of course, the same can be said of most NON-CORBA tcp/ip ports - which is why SOAP is the up-and-coming thing - it runs via the http ports.