Sign in to follow this  
Shaitan00

Sending an Object over TCP [CS/C# 2005]

Recommended Posts

I have a SERVER / CLIENT based chat interface (lobby) - the communication is done via TCP using TcpClients and TcpListeners - currently I have a working model using TcpClient and TcpListeners with NetworkStreams, StreamReaders, StreamWriters, etc.... At one point the CLIENT will ask the SERVER for the PLAYER LIST so it can be displayed to the users - in code the PlayerList is actually on the server as a DataSet (dsPlayerList.Tables["PlayerList"]) so when I send this to the Client I need to convert the results into a string and send it (using my StreamWriter.WriteLine and StreamWrite.Flush). It would be so much better if I could just send the DataSet [dsPlayerList] directly AS a DataSet and have it recovered at the other end AS a dataset and not need to perform any of these string conversions... Is such a thing possible? Any ideas, hints, and help would be greatly appreciated, thanks

Share this post


Link to post
Share on other sites
I believe a DataSet is marked Serializable, so you should be able to use a BinaryFormatter on it and turn it into a stream of bytes, which you can then send over the network, and then use a BinaryFormatter on the client to de-serialize it back into a dataset.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this