• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

writing vector object to I/O

 
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
i know it is possible to write a vector object through an I/O stream . If the vector contains unserialized objects say socket objects then will it be possible to write this vector object to the other end of the stream ?
Thanks in advance
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you try to serialize a Vector containing unserializable objects, you'll get a NotSerializableException.
 
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

Originally posted by Ernest Friedman-Hill:
If you try to serialize a Vector containing unserializable objects, you'll get a NotSerializableException.



So what can i do to avoid this exception ?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on what you're trying to do, I guess. I can imagine lots of possibilities: check the objects with instanceof before allowing them to be put into the Vector; run through the Vector before serializing it and check the objects; try, fail, and simply catch the exception... as I said, depends what you want to accomplish.
 
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

as I said, depends what you want to accomplish.[/QB]


I want to store socket objects inside a vector and write that vector object through an output stream so that that vector object can be recived at th other end with all the socket objects stored in it .
Thanks in advance
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you definitely can't do that. You could send a list of hostnames, or even a list of hostname/port pairs; but a Socket from one machine simply has no useful meaning on a second machine, so even if you could serialize it and send it, when it got to the other end, it would be useless. An open socket represents a connection between two machines; a third machine wouldn't be able to use it.
 
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

a third machine wouldn't be able to use it.[/QB]


Hmmm i got the point. So what can i do to implement a one to one chat . Please if you can follow the link below .
If the ISP has provided me with a static IP that means he has not selected the Obtain an IP address automatically option.
In that case when i log in to the internet , i still get an IP which is different from the static IP but is not reflected when i execute the ipconfig command.
I have an application which runs on a PC and listens for a connection. If the IP is not assigned automatically then that PC never listens for a connection and if it is assigned an IP automatically then the application works fine .
[ July 17, 2003: Message edited by: raghav mathur ]
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've looked at the thread mentioned in your signature; I think you haven't gotten any help here because it's obviously not a Java problem -- although if you pared your code down to one very small example and described your problem with regards to that, perhaps somebody might have something to say.
One thing that I want to say, although it's very possible that you already realize this, is that a machine with a dynamic IP really can't provide a service; no other machines would be able to find it, as its address may change from day to day (depends on the ISP, of course.)
Another thing: I'm not sure what your set-up looks like. You mentioned a LAN, so there are presumably more than one machine. If you've got a NAT router -- i.e., a box that connects to your ISP on one side, and all your computers on the other, then the IP address assigned by your ISP belongs to that NAT box, on the ISP side. The addresses "behind" the NAT box are invisible to the Internet at large; they're "make-believe", as it were. All that machines on the Internet will see is the NAT box's address; it's the NAT boxes job to figure out which internal machine packets from the Internet are intended for and different NAT boxes have different features so that this can be done in different ways. If your ISP assigns a dynamic address to the NAT box, and then the NAT box assigns dynamic addresses to your computers -- well, no wonder you can't get your chat server to work.
If you already know all the stuff in the paragraph above, then great. If you don't, but you suspect it might be related to your problem, then you should either find a local networking guru to explain it further, or maybe get a book on LANs.
 
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


One thing that I want to say, although it's very possible that you already realize this, is that a machine with a dynamic IP really can't provide a service; no other machines would be able to find it, as its address may change from day to day (depends on the ISP, of course.)
[/QB]


My application works on a machine which is assigned an IP automatically i.e on a machine where the IP is not specified .
Whereas it doesn't work maybe because of the NAT thing you've explained .
Any suggestions for a one to one private chat server?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic