I am writing at NTRIP client on WM6. Basically I am getting data from a server using sockets by first sending a configuration. But I am unable to get it working over a GPRS connection on the same device.
I send this message.
Get / HTTP/1.0
User-Agent: NTRIP client
Accept: */*
Connection: close
To this server.
Hostname: mamba.gps.caltech.edu
Port: 2101
I make the connection by doing this
string message = "GET / HTTP/1.0\r\nUser-Agent: NTRIP client\r\nAccept: */*\r\nConnection: close\r\n\r\n"
IPAddress ipAddress = Dns.GetHostEntry(hostname).AddressList[0];
_NTRIPCaster = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_NTRIPCaster.Connect(new IPEndPoint(ipAddress, Convert.ToInt32(port)));
_NTRIPCaster.Send(Encoding.ASCII.GetBytes(message));
for (int i = 0; i < 50; i++) //Wait for upto 5 seconds for a response
{
Thread.Sleep(100);
if (_NTRIPCaster.Available > 0)
{
Byte[] inBytes = new byte[_NTRIPCaster.Available];
_NTRIPCaster.Receive(inBytes);
sourceTable += Encoding.ASCII.GetString(inBytes, 0, inBytes.Length);
//Check if all of the Source table has been recieved
if (sourceTable.Contains("ENDSOURCETABLE"))
{
sourceTableRecieved = true;
break;
}
}
}
This all works fine if I have a Wi-Fi connection, or the device is docked to a PC and active sync is sharing the PCs internet connection.
If I cut off the internet on the PC, and disable the Wi-Fi then its unable to resolve the hostname to an IP address. Doesn’t even get to the socket connections. Basically it is not using the modem in the device and making use of a GPRS connection. This happens whether the GPRS is connected or not.
Since I am on WM6, I have looked at the connection manager API – http://msdn.microsoft.com/en-us/library/aa458120 .
But after following a few other posts I have been able to find on stackoverflow and other forums I have been unable to get it to work. Does anyone know how I can make a GPRS connection and start sending data to a server.
After alot of experimenting I got it to work.
Used the ConnectionManager, in SDF from OpenNetCF
Next, I used the TCP/IP method of connection. Honestly, I am not sure how this differs to sockets with a TCP protocol, as from what I can tell a TCPClient object, has a property called Client which itself is a socket. Stripped down sample of code below.
I am now getting data sent and received as expected.