I want to store sockets in my database and retrieve them also. But sockets are not serializable so I was unable to do this.
How can I store sockets in a database?
I want to store sockets in my database and retrieve them also. But sockets are not serializable so I was unable to do this.
How can I store sockets in a database?
What about the socket do you wish to store in the database? A socket itself represents something that cannot be stored in the databsae, but perhaps you can fetch the important attributes of a socket -- endpoints IP addresses, ports, and maybe some other important attributes if any -- and store those in the database as a proxy for the socket itself.
How do you want to store a socket in a database? Do you mean a data structure?
If it is a data structure you mean, then you could just store the sockets in a vector.
Vector yourNewPlaceToStoreSockets = new Vector();
yourNewPlaceToStoreSockets.add(yourSocketObject);
If you could be a bit more descriptive it would help me answer you better.
A socket that your program has access to is a transient entity that will be relinquished. What do you mean by storing it in the databaqse? What are you trying to do?
Do you actually mean a database (like an external database management system) or a data structure? Because you could place it in a collection.
You need to think about what you really need to store in the database that represents the "conversation" with the client in your particular application.
For example, it could be a (securely generated) random number/session ID allocated on the server and which the client passes up as a cookie. It might be an IP address/remote port, bearing in mind that they should be regarded as temporary.