|
|
Rank: Member Groups: Member
Joined: 9/22/2009 Posts: 4 Points: -85 Location: thai
|
i need to develop some software for vehicle tracking with XF.server for 64bit server
1. i need to know, i must to develop like a echo server or not, if i not need to send back message to blackbox. 2. i have 100 blackbox and setting interval of each blackbox @ 1 minute and i looking package size that sent to server not over 100 byte. pls recommend how to set a extened parameter.
Many thank every body.
|
|
Rank: Administration Groups: Administration
Joined: 2/15/2008 Posts: 130 Points: 835
|
Hi, 1. Yes it will look much the same, you should create a listener and read data from the accepted client connections. 2. You may use default settings (don't specify extended parameter). Despite of the small package size you should implement correct package framing, because the package may be delivered fragmented. What protocol does a blackbox use? In order to use XF.Network for commercial purpose on 64bit server you need to purchase a commercial license. Please contact office@kodart.com for details.
|
|
Rank: Member Groups: Member
Joined: 9/22/2009 Posts: 4 Points: -85 Location: thai
|
Many thank Admin and if have some question.
when i develop version of 1.windows service(C#) 2.console applocation(c#)
windows service was not stable, Some imcomming can receive normally but not in some incomming. I must manual restart service the incomming will commig again.
console application can receive all incomming correctly.
i donn't know why?.
|
|
Rank: Member Groups: Member
Joined: 9/22/2009 Posts: 4 Points: -85 Location: thai
|
Code for Windows service
static void Main() { using (IListener listener = Network.AcceptAsync(new IPEndPoint(IPAddress.Any, PORT_NUMBER), OnReadComplete)) { System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ServiceGatewayPool() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun); } }
protected override void OnStart(string[] args) { eventLog.WriteEntry("Service is prepare start.");
ClassFileINI ini;
try { ini = new ClassFileINI("C:\\xxx.ini");
............Read some parameter Thread.Sleep(100);
queueMessage = new Queue(QUEUE_SIZE);
//========== Asyncronize process timerQueue = new System.Timers.Timer(); timerQueue.Elapsed += new ElapsedEventHandler(OnQueueTimedEvent); timerQueue.Interval = QUEUE_INTERVAL; timerQueue.Enabled = true; //==========
eventLog.WriteEntry("Service is start."); } catch { eventLog.WriteEntry("Service is error on start queue."); } }
internal static void OnReadComplete(IConnection connection) { eventLog.WriteEntry("Incomming a message.");
connection.ReadAsync( delegate(IConnection a, IMemoryBuffer buffer) { if (buffer != null) { /* acquire buffer to use it in asynchronous operation */ buffer.Acquire();
string message = Encoding.ASCII.GetString(buffer.Data).Substring(0, buffer.BytesTransfered); string response = String.Format(responseFormat, message.Length, message);
/* send back received data */ connection.WriteAsync(buffer.Data, buffer.Offset, buffer.BytesTransfered, delegate { buffer.Release(); } );
message = message.Replace("\r", "").Replace("\n", ""); DoProcessQueue(message);
/* continue processing client requests */ OnReadComplete(connection); } else {
} } ); }
|
|
Rank: Member Groups: Member
Joined: 9/22/2009 Posts: 4 Points: -85 Location: thai
|
Code for Console application
static void Main() { using (IListener listener = Network.AcceptAsync(new IPEndPoint(IPAddress.Any, PORT_NUMBER), OnReadComplete)) { queueMessage = new Queue(QUEUE_SIZE);
//========== System.Timers.Timer timerQueue = new System.Timers.Timer(); timerQueue.Elapsed += new ElapsedEventHandler(OnTimedEvent); timerQueue.Interval = QUEUE_INTERVAL; timerQueue.Enabled = true; //==========
ConsoleKeyInfo cki; Console.TreatControlCAsInput = false; bool i = true; while (i == true) { cki = Console.ReadKey(true); if (cki.Key == ConsoleKey.X) { i = false; Console.WriteLine("Engine was stop, Press any key to exit."); Console.ReadKey(true); } } } }
internal static void OnReadComplete(IConnection connection) { Console.Write("Incomming message...."); Console.Write("\r\n");
connection.ReadAsync( delegate(IConnection a, IMemoryBuffer buffer) { if (buffer != null) { /* acquire buffer to use it in asynchronous operation */ buffer.Acquire();
string message = Encoding.ASCII.GetString(buffer.Data).Substring(0, buffer.BytesTransfered); string response = String.Format(responseFormat, message.Length, message);
/* send back received data */ connection.WriteAsync(buffer.Data, buffer.Offset, buffer.BytesTransfered, delegate { buffer.Release(); } );
message = message.Replace("\r", "").Replace("\n", "");
DoProcessQueue(message);
/* continue processing client requests */ OnReadComplete(connection); } } ); }
PLEASE ADVISE ME.
|
|
Rank: Administration Groups: Administration
Joined: 2/15/2008 Posts: 130 Points: 835
|
Hi,
In service implementation I would suggest you to create a listener in OnStart and dispose it in OnStop. Another point is that you use an older version of the component, please download a new release.
|
|
|
Guest |