A
Adam Goetz
I'm sure I'm close, just not quite there.
I have a eVC app and a CF.NET app, both are test apps at various stages of
completeness. Both are trying to connect to the same server from the same
handheld unit, though at different times of course.
So, what simple thing I have left out/gotten wrong?
eVC code that works:
.....
CString IP = "192.168.0.81";
destination_sin.sin_family = PF_INET;
destination_sin.sin_port = htons (4567);
LPTSTR tempIP;
char outIP[20];
tempIP = IP.GetBuffer(20);
for (int i = 0; i < IP.GetLength(); i++)
outIP = (char) tempIP;
outIP = 0;// terminate the string
destination_sin.sin_addr.s_addr = (DWORD) inet_addr(outIP);
if (connect (ClientSocket,
(struct sockaddr *) &destination_sin,
sizeof (destination_sin)) == SOCKET_ERROR)
{
wsprintf (szError, TEXT("Connecting socket failed. Error: %d"),
WSAGetLastError ());
MessageBox (szError);
closesocket (ClientSocket);
SetCursor(hOldCursor);
return;
};
.....
CF.NET code that returns "The requested address is not valid in its context"
.....
TcpClient client = new TcpClient();
try
{
client = new TcpClient(new IPEndPoint(IPAddress.Parse("192.168.0.81"),
4567));
}
catch (Exception e )
{
MessageBox.Show(e.Message);
}
.....
I have a eVC app and a CF.NET app, both are test apps at various stages of
completeness. Both are trying to connect to the same server from the same
handheld unit, though at different times of course.
So, what simple thing I have left out/gotten wrong?
eVC code that works:
.....
CString IP = "192.168.0.81";
destination_sin.sin_family = PF_INET;
destination_sin.sin_port = htons (4567);
LPTSTR tempIP;
char outIP[20];
tempIP = IP.GetBuffer(20);
for (int i = 0; i < IP.GetLength(); i++)
outIP = (char) tempIP;
outIP = 0;// terminate the string
destination_sin.sin_addr.s_addr = (DWORD) inet_addr(outIP);
if (connect (ClientSocket,
(struct sockaddr *) &destination_sin,
sizeof (destination_sin)) == SOCKET_ERROR)
{
wsprintf (szError, TEXT("Connecting socket failed. Error: %d"),
WSAGetLastError ());
MessageBox (szError);
closesocket (ClientSocket);
SetCursor(hOldCursor);
return;
};
.....
CF.NET code that returns "The requested address is not valid in its context"
.....
TcpClient client = new TcpClient();
try
{
client = new TcpClient(new IPEndPoint(IPAddress.Parse("192.168.0.81"),
4567));
}
catch (Exception e )
{
MessageBox.Show(e.Message);
}
.....