Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Storing Socket object in database

 
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is it possible ?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David
I hope i,am clear enough
It would be better if we continue this discussion on the Socket forum . PLease follow the link given below .
Thanks in advance
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I,am yet waiting for you
Please help me out .
I've really got stuck . This is very urgent .
Thanks in advance
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic