aspose file tools*
The moose likes I/O and Streams and the fly likes writing vector object to I/O Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "writing vector object to I/O" Watch "writing vector object to I/O" New topic
Author

writing vector object to I/O

Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
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


Raghav.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

If you try to serialize a Vector containing unserializable objects, you'll get a NotSerializableException.


[Jess in Action][AskingGoodQuestions]
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
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
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

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

Joined: Jan 12, 2001
Posts: 641
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
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

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

Joined: Jan 12, 2001
Posts: 641
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
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

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

Joined: Jan 12, 2001
Posts: 641

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: writing vector object to I/O
 
Similar Threads
Sorting a Vector by a specific language?
Sorting a Vector by a specific language?
Sorting a Vector by a specific language?
passing class name rather then object
Object Stream for large volume of data