Re: sethostname



OK, well, there's a couple things there.

1) Hmmm. I wonder if MFC is responsible for that. You might try
::sethostname(), although I don't see any evidence that MFC is trying to
hide it from you. You might also do a global search of your project for
"sethostname", in case you're doing something yourself to hide it from the
compiler. You can also right-click on the winsock.h string in your source
file and ask the compiler to open the source and make sure its the right
copy of winsock.h, the one in your SDK include directory. You *are* using
an SDK generated by Platform Builder *for your device*, right? Not
"standard SDK", not some other SDK, etc.?

2) Your actual call to sethostname() passes the wrong length. I found this
from experience. You want to pass strlen( name ) + 1, or you'll get an
invalid parameter error back.

Paul T.


"RML" <RML@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AADFC243-1936-4B05-9CB3-5C4E257DBDD2@xxxxxxxxxxxxxxxx
> Paul, the platform is X86 on an Advantec SBC running CE 4.2.
>
> Here is the top "#include section" of my cpp...
>
> // PorosityViewDlg.cpp : implementation file
> //
>
> #include <stdlib.h>
> #include <winsock.h>
> #include "stdafx.h"
>
> Here is the code that uses the function...
>
> BOOL CPorosityViewDlg::OnInitDialog()
> {
> CDialog::OnInitDialog();
>
> sethostname("Porosity1", 9);
> ...
>
> Here is the "compile" error...
>
> PorosityViewDlg.cpp
> D:\dev\Wabtec\PorosityTester\PorosityView\PorosityViewDlg.cpp(94) : error
> C2065: 'sethostname' : undeclared identifier
>
> RML
>
>
> "Paul G. Tobey [eMVP]" wrote:
>
>> Then I'd say that the platform doesn't have winsock in it. As Steve
>> said,
>> what platform is it? Are you sure that you're #including winsock.h?
>> Show
>> the code that does that from your program. Just to verify, this is a
>> *compile*, *not link*, error, right? It would be good to actually give
>> us
>> the text of the error messages when you want help with something like
>> this...
>>
>> Paul T.
>>
>> "RML" <RML@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:5C376BE8-5656-4209-9F6E-FF06E486B923@xxxxxxxxxxxxxxxx
>> > Hi Paul, I tried that and still get sethostname is undefined.
>> >
>> > RML
>> >
>> > "Paul G. Tobey [eMVP]" wrote:
>> >
>> >> Try just plain winsock.h and winsock.lib. I see sethostname() in the
>> >> winsock2.h header file, but there's some #if stuff around it and,
>> >> rather
>> >> than tracing through how that's supposed to be set, I'd just try this.
>> >>
>> >> Paul T.
>> >>
>> >> "RML" <RML@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> >> news:51E83CCC-0A6F-44BF-99CD-FBB7014E6AA5@xxxxxxxxxxxxxxxx
>> >> > Hi all, In my CE 4.2 VC++ app I am trying to set the Host name by
>> >> > using
>> >> > "sethostname()". I have added winsock2.h & ws2.lib to my build but
>> >> > get
>> >> > a
>> >> > compile error indicating that sethostname is undefined.
>> >> >
>> >> > Can anyone help?
>> >> >
>> >> > RML
>> >> >
>> >>
>> >>
>> >>
>>
>>
>>


.



Relevant Pages

  • Re: Running MFC Apps on Pocket PC
    ... You probably want to use the Pocket PC 2003 ... Note that MFC is peculiar in that the PPC2003 SDK uses the CE3 ... libraries even though PPC2003 is a CE4 platform. ...
    (microsoft.public.pocketpc.developer)
  • Re: eVC4 and Visual Studio 2005
    ... platform?, etc.), and maybe that's causing some problem with the project ... Paul T. ... [about possibility of using CE5 SDK with VS2005] ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: mfc selbst kompilieren
    ... Jetzt möchte ich mit dem beim SDK mitgelieferten aktualisierten ... Im Platform SDK-Verzeichnis habe ich sie nicht gefunden. ... Im allgemeinen würde ich nicht dazu raten, die MFC neu zu kompilieren, ... IIRC gibt es für die MFC ein Makefile. ...
    (microsoft.public.de.vc)
  • Re: fatal error LNK1104: cannot open file mfcs42d.lib
    ... I have included MFC in my platform. ... So my SDK have the library. ... >> Paul T. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: How to clone a Windows CE 5.0 OS design
    ... Platform ID didn't match because PB sometimes doesn's update platform ID ... Also, if I already installed the SDK built using the old PlatformGuid, I ... Many Thanks again Paul. ... Well a GUID is a GUID, ...
    (microsoft.public.windowsce.platbuilder)