Page 203 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 203

PDA 09  5/27/03  8:50 AM  Page 179
                                            Chapter 9 / PDA Robot Software for Pocket PC 2002
                                   //
                                   BOOL          Found = FALSE;
                                   UCHAR        *pPI, *pPL, *pPV;
                                   //
                                   // for the setsockopt call to enbale 9 wire IrCOMM
                                   //

                                   int  Enable9WireMode  = 1;
                                   CString msg;

                                   SOCKADDR_IRDA DstAddrIR = { AF_IRDA, 0, 0, 0, 0, "IrDA:IrCOMM" };
                                   //
                                   // Create the Infrared Socket
                                   //
                                   if ((Infrared_Socket = socket(AF_IRDA, SOCK_STREAM, NULL)) == INVALID_SOCKE{
                                      //
                                      // Get the error and display it in the status edit box
                                      //

                                      int last_error = WSAGetLastError();
                                      if (last_error == WSAESOCKTNOSUPPORT)
                                      {
                                        //
                                        // MessageId: WSAESOCKTNOSUPPORT
                                        //
                                        // MessageText:
                                        //
                                        //  The support for the specified socket type does not exist
                                        //  in this address family.
                                        //
                                        char err_buff[10];
                                        _itoa(last_error, &err_buff[0], 10);
                                        msg = "Error: ";
                                        msg += err_buff;
                                        msg = "no support for type in this address family";
                                        AfxMessageBox(msg);

                                      }else{
                                        msg = "Couldn't get socket ";
                                        this->m_status_window.SetWindowText( (LPCTSTR) msg);
                                      }
                                      return false;

                                                                                               179
   198   199   200   201   202   203   204   205   206   207   208