🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
4 messages
4 total messages Started by Mike K Wed, 26 Mar 2008 22:33
Safe to modify machine-generated headers?
#366
Author: Mike K
Date: Wed, 26 Mar 2008 22:33
13 lines
2092 bytes
Hope this is posted to the right group; the problem surfaced when I created an app that uses TCP sockets.

I'm using the WinPCap library to create raw sockets in promiscuous mode. This uses winsock2.h, which is based on winsock 2.2.  

The app compiles and runs fine.  I also need to open a standard TServerSocket to open a pipe to another application. As soon as I drop this component onto the form, the compiler complains about a multiple declaration for 'fd_set', which is defined in both winsock.h and winsock2.h.  Turns out the Borland native components call winsock.h in WinSock.hpp, so both winsock header files are used, creating the conflict.

Can I modify WinSock.hpp to call winsock2.h instead of winsock.h without destroying previous projects, or creating some kind of rift in the time-space continuum?  The change seems innocuous enough, but WinSock.hpp explicitly states "dont modify this machine-generated header".  Does this mean that even if I change the reference from winsock to winsock2, it will be overwritten anyway?  

For various reasons, I'd like to have (int the same application) the use of both my standard Borland socket components and the WinPcap library as well.

TIA

Mike 
Re: Safe to modify machine-generated headers?
#367
Author: Mike K
Date: Wed, 26 Mar 2008 22:35
1 lines
1212 bytes
Anyway, I went ahead and modified the WinSock.hpp to call winsock2.h, and everything works.  My question is still, am I creating problems for my other existing and future apps?
Re: Safe to modify machine-generated headers?
#368
Author: Remy Lebeau (TeamB)
Date: Wed, 26 Mar 2008 23:19
35 lines
2567 bytes
"Mike K" <nospam@nospam.net> wrote in message 
news:47eacf28$1@newsgroups.borland.com...

> I also need to open a standard TServerSocket to open a pipe
> to another application. As soon as I drop this component onto
> the form, the compiler complains about a multiple declaration
> for 'fd_set', which is defined in both winsock.h and winsock2.h.

winsock.h and winsock2.h do not coexist together.  That is Microsoft's 
mistake.  They copied all of winsock.h's data structures and macros into 
winsock2.h, instead of having winsock2.h simply #include winsock.h for them 
instead.  I do not know why they did that, but it is a real pain to get 
around, and doubly so since you are involving the VCL.

Basically, you need to separate your winsock2.h-based code from your 
winsock.h-based code.  Put them into completely separate units so the two 
headers have no chance of colliding with each other.  Better if you can move 
one of them into a completely separate project, such as a static .lib that 
you can then include into the main application once compiled.

> Can I modify WinSock.hpp to call winsock2.h instead of winsock.h

I would not recommend that.

> For various reasons, I'd like to have (int the same application) the use
> of both my standard Borland socket components and the WinPcap
> library as well.

Do you have the option of using different TCP components?  Indy, for 
instance, uses winsock2.h instead of winsock.h.  You may want to consider a 
change anyway, since TServerSocket and TClientSocket are deprecated now.


Gambit 
Re: Safe to modify machine-generated headers?
#369
Author: Mike K
Date: Thu, 27 Mar 2008 04:02
43 lines
2801 bytes
Actually, you're right; I have Indy components installed and I will use them instead  - it's just for this one application anyway.

thanks...



Remy Lebeau (TeamB) wrote:
> "Mike K" <nospam@nospam.net> wrote in message 
> news:47eacf28$1@newsgroups.borland.com...
> 
>> I also need to open a standard TServerSocket to open a pipe
>> to another application. As soon as I drop this component onto
>> the form, the compiler complains about a multiple declaration
>> for 'fd_set', which is defined in both winsock.h and winsock2.h.
> 
> winsock.h and winsock2.h do not coexist together.  That is Microsoft's 
> mistake.  They copied all of winsock.h's data structures and macros into 
> winsock2.h, instead of having winsock2.h simply #include winsock.h for them 
> instead.  I do not know why they did that, but it is a real pain to get 
> around, and doubly so since you are involving the VCL.
> 
> Basically, you need to separate your winsock2.h-based code from your 
> winsock.h-based code.  Put them into completely separate units so the two 
> headers have no chance of colliding with each other.  Better if you can move 
> one of them into a completely separate project, such as a static .lib that 
> you can then include into the main application once compiled.
> 
>> Can I modify WinSock.hpp to call winsock2.h instead of winsock.h
> 
> I would not recommend that.
> 
>> For various reasons, I'd like to have (int the same application) the use
>> of both my standard Borland socket components and the WinPcap
>> library as well.
> 
> Do you have the option of using different TCP components?  Indy, for 
> instance, uses winsock2.h instead of winsock.h.  You may want to consider a 
> change anyway, since TServerSocket and TClientSocket are deprecated now.
> 
> 
> 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