|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Socket programming help
hi,
ok this is what i'm trying to do. i'm trying a simple server/client program to send a string and then an object(vector). i can send them both seperately but not both together. anyone know why? on the server side i have sock = new ServerSocket(serverPort); clientSocket = sock.accept(); o = new DataOutputStream (new BufferedOutputStream (clientSocket.getOutputStream ())); vectorObj = new ObjectOutputStream(clientSocket.getOutputStream()); Vector handlers = new Vector(); handlers.addElement("bananas"); handlers.addElement("milk"); handlers.addElement("coffee"); o.writeUTF ("blah blah"); o.flush(); vectorObj.writeObject(handlers); clientSocket.close(); sock.close(); and on the client side i first read the string (blah blah) and it works fine, but when i try to read the object it doesn't work. if i comment out o.writeUTF ("blah blah"); and o.flush(); i can then read the object.... any ideas? cheers ciaran |
|
#2
|
|||
|
|||
|
It sounds like you're doing the correct thing but we need a complete code sample. It's very difficult to determine what the issue is with just a partial sample.
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums. |
|
#3
|
||||
|
||||
|
I suspect that you accidentally read a part of the object as well and thus "corrupt" the object in the stream...
You should be able to send String objects through the ObjectOutputStream. Try that and see if it helps.
__________________
- Hugh of Borg The first thing young borg are taught: Keep away from Microsoft software! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Socket programming help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|