sorry for late replay it didn't work still 92% CPU after 20 min with only 4 devices i put stream.close inside the catch i put clientsocket.close inside the catch the error was cannot access a disposed object system.net.sockets.socket should i use Async Asynchronous Server Socket
maher khalil
Posts
-
Theading with TCPListner Optimization -
Theading with TCPListner Optimizationi tried that it got worse it hang after starting by 2 minutes
-
Theading with TCPListner Optimizationyou are right about closing the network stream and the clients could you point out where in the code to do so
-
Theading with TCPListner Optimizationi'm using
using (SqlConnection conn = new SqlConnection(ConnStr))
{
conn.Open();
using (SqlCommand comm = new SqlCommand("Select id from T_SafeArea", conn))
{} conn.Close(); conn.Dispose(); }
-
Theading with TCPListner Optimizationi guess you are right please check that code part
while (true)
{
counter += 1;
clientSocket = serverSocket.AcceptTcpClient();handleClinet client = new handleClinet(); client.startClient(clientSocket, Convert.ToString(counter)); } clientSocket.Close(); serverSocket.Stop();
it will never go to the close part
-
Google map Context MenuHi all i am creating gps tracking system i have to do two things with the marker 1- create context menu with some functions on the marker 2- add car number as label on the marker the first thing is finished Map With Context Menu when i tried to do the second issue a conflict (i think) happened i included a JS library Map Label Library both are working alone but when combined no thin work code after combine Map With Labels and Context Menu some details both depend on overlay errors TypeError: a.lng is not a function ...b=b||new _.G(0,0);var c=this.b;b.x=c.x+a.lng()*this.j;a=_.Za(Math.sin(_.Sb(a.lat... InvalidValueError: not a LatLng or LatLngLiteral: in property lat: not a number TypeError: c.lat is not a function ...,c=d.b.search(_.vi)):(c=a.ca,c=new _.G(c.lat(),c.lng()),a.da=c,_.uJ(d.j,{da:c,ye... InvalidValueError: not a LatLng or LatLngLiteral: in property lat: not a number Thank You
-
Theading with TCPListner OptimizationHi All i'm working on gps tracking system now i'm working on receiving data from gps devices throw tcp port using tcpListner class then arrange the data then save it to sql server i have created a console application to do so then convert it to windows service using NSSM it is working as expected but after about 30 minutes it consumes all the server memory and CPU it is only 4 devices connected (Test Phase) The Code
using System;
using System.Threading;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Data;
using Microsoft.SqlServer.Types;
using System.Linq;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TcpListener serverSocket = new TcpListener(8889);
TcpClient clientSocket = default(TcpClient);
int counter = 0;serverSocket.Start(); // Console.WriteLine(" >> " + "Server Started"); counter = 0; while (true) { counter += 1; clientSocket = serverSocket.AcceptTcpClient(); // Console.WriteLine(" >> " + "Client No:" + Convert.ToString(counter) + " started!"); handleClinet client = new handleClinet(); client.startClient(clientSocket, Convert.ToString(counter)); } clientSocket.Close(); serverSocket.Stop(); // Console.WriteLine(" >> " + "exit"); Console.ReadLine(); } } //Class to handle each client request separatly public class handleClinet { static void WriteLog(string message, EventLogEntryType type) { using (EventLog eventLog = new EventLog("Application")) { eventLog.Source = "Application"; eventLog.WriteEntry(message, type, 101, 1); } } static int InsideDangerArea(double Lat, double Lng) { string point = "POINT(" + Lng + " " + Lat + ")"; string ConnStr = "Data Source =.; Initial Catalog = GPS\_Tracking;Integrated Security = True"; using (SqlConnection conn = new SqlConnection(ConnStr)) { conn.Open(); using (SqlCommand comm = new SqlCommand