Page 214 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 214
PDA 09 5/27/03 8:50 AM Page 190
char szHostName[25];
// PDA Robotics
// Get the name of the PDA this is running and send it
// to the command Centre.
//
gethostname(szHostName,25);
m_pSocket->Send (szHostName,25,0);
char szUsername[255];
char szPassword[255];
strcopy(szUsername,m_strUsername);
strcopy(szPassword,m_strPassword);
//
//send the user name and the password
//
m_pSocket->Send (szUsername,255,0);
m_pSocket->Send (szPassword,255,0);
return TRUE;
}
//
// ConnectSocket Creates the CPDASocket which is derived from a CCeSocket
// and attempte to connect to the remote host that the control center is
// running on.
//
BOOL CPDABotDlg::ConnectSocket(LPCTSTR lpszHandle, LPCTSTR lpszAddress, UINT
nPort)
{
m_pSocket = new CPDASocket(CCeSocket::FOR_DATA);
if (!m_pSocket->Create())
{
delete m_pSocket;
m_pSocket = NULL;
this->m_status_window.SetWindowText( (LPCTSTR) CString("Can't create sock") );
return FALSE;
}
if(!m_pSocket->Connect(lpszAddress, nPort + 700))
{
this->m_status_window.SetWindowText( (LPCTSTR) CString("Failed to connect") );
delete m_pSocket;
m_pSocket = NULL;
return FALSE;
190