Re: sethostname
- From: "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
- Date: Mon, 18 Apr 2005 15:02:44 -0700
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
>> >> >
>> >>
>> >>
>> >>
>>
>>
>>
.
- References:
- sethostname
- From: RML
- Re: sethostname
- From: Paul G. Tobey [eMVP]
- Re: sethostname
- From: RML
- Re: sethostname
- From: Paul G. Tobey [eMVP]
- Re: sethostname
- From: RML
- sethostname
- Prev by Date: Re: sethostname
- Next by Date: Re: sethostname
- Previous by thread: Re: sethostname
- Next by thread: Re: sethostname
- Index(es):
Relevant Pages
|