HI, I have an applet which creates a socket to a server . I want to be able to send this socket to a servlet. I am sending a string from the applet to the servlet (using writeObject) but that doesn't work for sending the socket . I keep getting a "not serializable" error. I set the requestProperty as follows: servletConnection2.setRequestProperty("Content-Type","application/octet-stream");
How can I send a socket from applet to a servlet. thanks in advance. G. [ January 06, 2005: Message edited by: Gauri Deshmukh ]
Can't be done. The simple answer is that java.net.Socket does not implement java.io.Serializable and therefore cannot be serialized (see the . Java Tutorial: Object Serialization for more about that). The more in-depth answer is that a socket is not a resource like a file which can be read in and transmitted. It is an operating system abstraction of a very real, physical thing: the network cable plugged into the back of your computer. What you are trying to do is like trying to stuff one end of your network cable in an envelope and mail it to a friend. It won't get far!