HI Is it possible to store a Socket Object in the database(MySql) which can be retrieved later when required. when the server accpets a connection , it spawns a new socket for each connection so that the required input/output stream can be opened . Now i want to store this socket object and mantain a list so that when a pirticular socket is being selectd from the database , then the inpu/output stream should open for that pirticular socket only . I hope i,am clear enough Please guide me a bit Thanks in advance
1) I really don't think so 2) I really hope not. Sockets aren't distributable ie you can't move it from one machine to another. It isn't Serializable etc. It represents an active connection between your machine and the remote machine, and the connection needs to be supported at both ends. If you did manage some way to persist it, your side would no longer be active and the remote computer would disconnect. If you found away to recreate the Socket, the other end would no longer exist. I saw a while ago someone trying to do something similar in trying to synchronize requests to a server, and it failed horribly. Dave
From browsing your other thread, if the remote machine will accept connections you can store the socket settings as a host and port in the database then attempt to reconnect with the client when ready. You would be creating a new Socket each time, as opposed to persisting the Socket instance.
That's what i,am doing : 1) A client connects to the actual server. 2) The server retrives the IP and the port of the connected client and stores them in the database. 3) The server sends back the port from which the client is connected so that the client can now listen for incomming connections on that pirticular port returned by the server. At this stage the link between the client and server closes and the client is now ready to accept just one connection. 4) Finally a third interface (i call it external client)which sees all the conneted clients and on selecting a pirticular client it gets the coresponding ip and port of that client ( which is now ready to listen for just one connection so that the conversation with the external client begins). The external client makes a socket connection to the client( which is now listening for a connection) but couldn't make it ? I tried to ping the machine on which the client( which was now listening for a connection) but it didn't ping . I know unless it doesn't ping my socket connectivity won't take place but is my overall design ok? I've tested this application locally and it works . What could be the reason that it doesn't work on the internet( besides the pinging thing). I don't even know why the hell it was not pinging whereas i tried the other way round.I tried to ping from the machine where the client( which is listening for connections) is running to the machine where the external client is trying to make connection to the connected clients and it did ping . What do you say ? Once again ... this application works fine locally ( on our Local Area Network ) . Thanks in advance
Originally posted by David O'Meara: From browsing your other thread, if the remote machine will accept connections you can store the socket settings as a host and port in the database then attempt to reconnect with the client when ready. You would be creating a new Socket each time, as opposed to persisting the Socket instance.
[ July 09, 2003: Message edited by: raghav mathur ] [ July 09, 2003: Message edited by: raghav mathur ] [ July 10, 2003: Message edited by: raghav mathur ]