dcsimg
Sockets, universal writing/reading mehod ?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alexander_Shalamov
Posted On:   Thursday, March 21, 2002 09:18 AM

In my client/server application, Client sends various types of data (string, int, and so on). How can i handle all data types at server side ?

Server can take only a string, if i send int it also takes input as bytes array, so its good for string but not for other data types.

If there some universal method which can read any data types from sockets ? Or how can i solve this problem using standard sockets writer/reader ?

Re: Sockets, universal writing/reading mehod ?

Posted By:   Stephen_Ostermiller  
Posted On:   Thursday, March 21, 2002 12:53 PM

It sounds like you need a protocol to use over your connection.


You need to make sure that your client and server are speaking the same langauge. Send some protocol identifier and version.


You need to have a format for your data. Hove you looked into using an existing protocol or using an existing data format? Think XML maybe?

Re: Sockets, universal writing/reading mehod ?

Posted By:   Christopher_Schultz  
Posted On:   Thursday, March 21, 2002 12:51 PM

If you want, you can use an ObjectInputStream and ObjectOutputStream and pass Serializable Java objects back and forth.



-chris
About | Sitemap | Contact