Fast possiblity to send data from Server to Client
-
Hello, I search for a fast possibility to send data from a server to the client. It should be possible to send the data from one PC to the other. For some other functions the server implements at the moment a remote interface with RegisterWellKnownServiceType... What is the best possibity to send data (in worst case it could be about 1Mb/s) to the client? Best regards Hansjörg
-
Hello, I search for a fast possibility to send data from a server to the client. It should be possible to send the data from one PC to the other. For some other functions the server implements at the moment a remote interface with RegisterWellKnownServiceType... What is the best possibity to send data (in worst case it could be about 1Mb/s) to the client? Best regards Hansjörg
-
Hello, I search for a fast possibility to send data from a server to the client. It should be possible to send the data from one PC to the other. For some other functions the server implements at the moment a remote interface with RegisterWellKnownServiceType... What is the best possibity to send data (in worst case it could be about 1Mb/s) to the client? Best regards Hansjörg
Seems you are using Remoting and in .NET remoting you can send streams from server side to client with requesting it from the client area I used it for sending none shared files from the server to client and the speed was far more 1MByte/Sec (but this method is not such a secure one for file sharing!) and ofcourse with sending streams you can send all types of data (so you can send your instances as Data with serializing them on the fly in memory stream and then send the stream to client) I can't give you a complete code because it was part of a bigger project and I must send you lots of code to work but here is the code I wrote for testing it is possible to do this or not sorry the code is somewhat messy (it was for testing puposes only) the share part
namespace NetTest
{
public class RemoteFileBrowser:MarshalByRefObject
{
public delegate void EventFireHandler();
public event EventFireHandler eventFiredFromRemoteObject;public RemoteResult GetStream(string path) { if (!File.Exists(path)) return new RemoteResult(); return new RemoteResult(new FileStream(path, FileMode.Open)); } public RemoteResult Failed() { return new RemoteResult(); } public string GetMachineName() { return Environment.MachineName; } public string GetAuthor() { if (this.eventFiredFromRemoteObject != null) this.eventFiredFromRemoteObject(); return "Hessam Jalali"; } }
}
the server side
class Program { static void Main(string\[\] args) { Console.WriteLine("Host Started"); TcpChannel tc = new TcpChannel(50000); ChannelServices.RegisterChannel(tc,false); RemoteFileBrowser rfb = new RemoteFileBrowser(); rfb.eventFiredFromRemoteObject += new RemoteFileBrowser.EventFireHandler(rfb\_eventFiredFromRemoteObject); RemotingConfiguration.RegisterWellKnownServiceType(rfb.GetType(), "rfb.rem", WellKnownObjectMode.Singleton); Console.WriteLine(); Console.WriteLine("Press any key to Exit..."); Console.ReadKey(); ChannelServices.UnregisterChannel(tc); } static void rfb\_eventFiredFromRemoteObject() { Console.WriteLine("Event Fired inside"); } }
and the client side
-
Seems you are using Remoting and in .NET remoting you can send streams from server side to client with requesting it from the client area I used it for sending none shared files from the server to client and the speed was far more 1MByte/Sec (but this method is not such a secure one for file sharing!) and ofcourse with sending streams you can send all types of data (so you can send your instances as Data with serializing them on the fly in memory stream and then send the stream to client) I can't give you a complete code because it was part of a bigger project and I must send you lots of code to work but here is the code I wrote for testing it is possible to do this or not sorry the code is somewhat messy (it was for testing puposes only) the share part
namespace NetTest
{
public class RemoteFileBrowser:MarshalByRefObject
{
public delegate void EventFireHandler();
public event EventFireHandler eventFiredFromRemoteObject;public RemoteResult GetStream(string path) { if (!File.Exists(path)) return new RemoteResult(); return new RemoteResult(new FileStream(path, FileMode.Open)); } public RemoteResult Failed() { return new RemoteResult(); } public string GetMachineName() { return Environment.MachineName; } public string GetAuthor() { if (this.eventFiredFromRemoteObject != null) this.eventFiredFromRemoteObject(); return "Hessam Jalali"; } }
}
the server side
class Program { static void Main(string\[\] args) { Console.WriteLine("Host Started"); TcpChannel tc = new TcpChannel(50000); ChannelServices.RegisterChannel(tc,false); RemoteFileBrowser rfb = new RemoteFileBrowser(); rfb.eventFiredFromRemoteObject += new RemoteFileBrowser.EventFireHandler(rfb\_eventFiredFromRemoteObject); RemotingConfiguration.RegisterWellKnownServiceType(rfb.GetType(), "rfb.rem", WellKnownObjectMode.Singleton); Console.WriteLine(); Console.WriteLine("Press any key to Exit..."); Console.ReadKey(); ChannelServices.UnregisterChannel(tc); } static void rfb\_eventFiredFromRemoteObject() { Console.WriteLine("Event Fired inside"); } }
and the client side
I'm not sure at the moment if this works. The main purpose of this application is to send the log data to other connected clients. For that I don't wan't to poll allways the server.. but maybe that there is possibility to use the stream! do you know if it is possible to deserialize objectes allways from the same stream? Best regards and many thanks
-
I'm not sure at the moment if this works. The main purpose of this application is to send the log data to other connected clients. For that I don't wan't to poll allways the server.. but maybe that there is possibility to use the stream! do you know if it is possible to deserialize objectes allways from the same stream? Best regards and many thanks
hansipet wrote:
do you know if it is possible to deserialize objectes allways from the same stream?
If you mean one stream for all Yes it is possible but you must set the pointers of the stream manually eachtime by yourself for preventing errors.and ofcourse you need some implementation for preventing asynchronous calls from clients for requesting the stream and update requests from the server on the that. and if you mean same stream as serialized in request the answer is yes again and this time you just need to set the pointers to first of the stream with using methods like seek
hansipet wrote:
I don't wan't to poll allways the server
if you said that because of the singleton it can be singleCall so after calling and disposing the stream the resources from server side will release and there would be no problem. but if your Log files are not so huge I think creating a class as LogDataHolder and mark it as serializible then return it as value to clients would be a better idea. good luck