Answer 1
Hi,
In this moment, I'm working on the same project too, gprs data is datagram packets, so we need a UDP socket that listens in an specific IP and port, to test, i began by writing console application in C#, i launched it in my VPS,
private const int UdpPort = 8002;
private const string sIPAdress = "A.B.C.D";
public GpsListner()
{
Inits();
}
public void Inits()
{
try
{
UdpThread = new Thread(new ThreadStart(StartReceive));
UdpThread.Start();
Console.WriteLine("AStarted GPS Server");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("An UDP Exception has occurred!" + ex.ToString());
}
}
public void StartReceive()
{
try
{
IPEndPoint localIpEndPoint = new IPEndPoint(IPAddress.Parse(sIPAdress), UdpPort);
UdpClient Udp = new UdpClient(localIpEndPoint);
Console.WriteLine("Start to Receive on :" + sIPAdress, EventLogEntryType.Information);
while (true)
{
Console.WriteLine("In Loop", EventLogEntryType.Information);
IPEndPoint tmpIpEndPoint = new IPEndPoint(IPAddress.Parse(sIPAdress), UdpPort);
EndPoint remoteEP = (tmpIpEndPoint);
Byte[] received = Udp.Receive(ref tmpIpEndPoint);
String device_id = null;
Console.WriteLine("GPS is connected through UDP From: " + tmpIpEndPoint.ToString() + "\n" + BitConverter.ToString(received) + "\n" + "Packet Size :" + received.Length, EventLogEntryType.Information);
}
}
catch (SocketException se)
{
Console.WriteLine("A Socket Exception has occurred!" + se.ToString());
}
}
Now, when i send an asynchronous string remotly from a client socket, the socket server catch the data but when sending packets from gprs unit nothing happens
I hope that we can find a solution together
Thank you