Thread View: borland.public.cppbuilder.internet.socket
8 messages
8 total messages
Started by DeKayA
Mon, 30 Oct 2006 03:54
WSADATA and BCB4 Windows app
Author: DeKayA
Date: Mon, 30 Oct 2006 03:54
Date: Mon, 30 Oct 2006 03:54
29 lines
1519 bytes
1519 bytes
Hi
With many thanks to Michel Leunen
I was able to get my console ping working.
Now I am trying to set it up in a windows app.
I can't seem to even get off the ground though.
Where is WSAData defined.
In the console app I simply used
WSADATA wsa;
However i get the error
2451 Undefined symbol WSADATA
I included <windows.h>
I have looked at code submitted/corrected in the news group but I am
missing something.
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
WSADATA wsa = {0};
int ret = WSAStartup(MAKEWORD(1, 0), &wsa);
WasInitialized = ( ret != 0 );
if( !WasInitialized ) MessageBox(NULL, ("Startup Error " +
AnsiString(ret)).c_str(),
"Error", MB_OK | MB_ICONERROR);
Re: WSADATA and BCB4 Windows app
Author: Remy Lebeau (TeamB)
Date: Mon, 30 Oct 2006 04:12
Date: Mon, 30 Oct 2006 04:12
19 lines
1326 bytes
1326 bytes
<DeKayA@bellsouth.net> wrote in message news:45467532.54908193@forums.borland.com... > Where is WSAData defined. In winsock.h, where all of the other WinSock functions and structures are defined. > In the console app I simply used > WSADATA wsa; > > However i get the error > 2451 Undefined symbol WSADATA Did not include winsock.h? Gambit
Re: WSADATA and BCB4 Windows app
Author: DeKayA
Date: Mon, 30 Oct 2006 13:37
Date: Mon, 30 Oct 2006 13:37
24 lines
1373 bytes
1373 bytes
>Did not include winsock.h?
Yea I deserved that.
Since I don't think its possible to look any more stupid...
Why was it not required in the console app? A couple of messages
back. Did this somehow load it?
hIcmp = LoadLibrary( "ICMP.DLL" );
Where is the default destructor?
When I add this is says it has already been defined.
I can't seem to locate it, looked in header.
__fastcall TForm1::~TForm1()
{
if( WasInitialized )
WSACleanup();
}
Is it onclose()?
Thanks
Re: WSADATA and BCB4 Windows app
Author: Remy Lebeau (TeamB)
Date: Mon, 30 Oct 2006 18:10
Date: Mon, 30 Oct 2006 18:10
37 lines
2239 bytes
2239 bytes
<DeKayA@bellsouth.net> wrote in message
news:4546ff52.90268529@forums.borland.com...
> Why was it not required in the console app?
You probably included something else that then implicitally included
winsock.h for you.
> Did this somehow load it?
No.
> Where is the default destructor?
There is no such thing as a 'default' destructor, because a destructor
cannot be overloaded. Now, if you are asking why TForm classes do not have
a destructor defined in the header file by default, it is becuse they don't
need one by default. There is nothing in the default code of the class that
needs explicit destroying in your code, so the compiler-generated destructor
will suffice. If you need to destroy something yourself, then you have to
add a destructor to your code as needed.
> When I add this is says it has already been defined.
You probably did not define the destructor in your header file:
public:
__fastcall TForm1(TComponent *Owner);
__fastcall ~TForm1(); // <-- add this manually
> Is it onclose()?
No. That is an event that has nothing to do with the destructor.
Gambit
Re: WSADATA and BCB4 Windows app
Author: DeKayA
Date: Mon, 30 Oct 2006 21:01
Date: Mon, 30 Oct 2006 21:01
40 lines
2300 bytes
2300 bytes
>> Why was it not required in the console app? > >You probably included something else that then implicitally included >winsock.h for you. Well I don't know where, since these #include <windows.h> #include <stdio.h> are the only two includes in the original functioning console program. Which is why I previously wondered why my console program worked without winsock.h explicitly included. I had previously erroneously thought (prior to your redirection) windows.h did it. >If you need to destroy something yourself, then you have to >add a destructor to your code as needed. >> When I add this is says it has already been defined. >You probably did not define the destructor in your header file: > > public: > __fastcall TForm1(TComponent *Owner); > __fastcall ~TForm1(); // <-- add this manually At first I wondered why I would have to define the destructor in my header file, if it was complaining that it had already been defined. But you are right. I added it to the header and it quit complaining that it had already been defined. You can see my confusion with the error message "ALREADY DEFINED" ! So I guess by putting one in the header you effectively override the one the compiler would have used. So off to further learning Thanks
Re: WSADATA and BCB4 Windows app
Author: Remy Lebeau (TeamB)
Date: Mon, 30 Oct 2006 22:52
Date: Mon, 30 Oct 2006 22:52
13 lines
1345 bytes
1345 bytes
<DeKayA@bellsouth.net> wrote in message news:45476653.2782591@forums.borland.com... > Well I don't know where, since these > #include <windows.h> > #include <stdio.h> > are the only two includes in the original functioning console program. windows.h includes winsock.h Gambit
Re: WSADATA and BCB4 Windows app
Author: Bob Gonder
Date: Tue, 31 Oct 2006 02:40
Date: Tue, 31 Oct 2006 02:40
5 lines
1219 bytes
1219 bytes
Remy Lebeau (TeamB) wrote: >windows.h includes winsock.h But only #if (_WIN32_WINNT >= 0x0400)
Re: WSADATA and BCB4 Windows app
Author: Remy Lebeau (TeamB)
Date: Tue, 31 Oct 2006 06:18
Date: Tue, 31 Oct 2006 06:18
11 lines
1414 bytes
1414 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message news:iqddk2dgkb5g203mn7rrhkddeluppenp1n@4ax.com... > But only #if (_WIN32_WINNT >= 0x0400) _WIN32_WINNT is set in windows.h to 0x0500 by default, unless defined by the user's project in the Conditionals list. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads