stijnsanders / TMongoWire

Delphi MongoDB driver
MIT License
102 stars 37 forks source link

Compatibility xe6 #21

Closed johnidm closed 9 years ago

johnidm commented 9 years ago

Hi,

I have to use TMongoWire with Delphi XE6, but occurred error "[dcc32 Fatal Error] mongoWire.pas(5): F1026 File not found: 'C:\Users\johni\Downloads\MongoDBDelphiTMongoWire-master\prj\Sockets.dcu'"

The lib Sockets it not exists in Delphi XE6.

I can to change TTcpClient to TSocketClient.

johnidm commented 9 years ago

Other alternative is to install component InetWinSockets.

http://docwiki.embarcadero.com/CodeExamples/XE6/en/VCL.InetWinSockets_Sample http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE6/Object%20Pascal/VCL/InetWinSockets/

What do you think, refactory TTcpClient to TSocketClient or to install InetWinSockets in Delphi XE6?

malcolmgroves commented 9 years ago

I just took a stab at this for XE7 here https://github.com/malcolmgroves/TMongoWire/commit/53c5550d08e0463b6bd916c4677841353a02868d

Definitely needs more testing, but simple demos seem to work.

Note, I did a very literal translation of the existing socket code to Indy. It could very well be made more efficient by someone who knows Indy better than I and can leverage its strengths.

stijnsanders commented 9 years ago

I've made a really-basic wrapper around blocking sockets straight from WinSock2 here: https://github.com/stijnsanders/xxm/blob/master/Delphi/http/xxmSock.pas I'll lt you know if I can make some time to see if I can base TMongoWire on this one also.

malcolmgroves commented 9 years ago

Main reason I was looking at Indy was for cross-platform. Just testing it now but it appears the Indy-based version works on OSX and might work on Android/iOS. I'm assuming your WinSock2 version would not, is that right?

Update: scratch that. I can connect, but there are OLE dependencies in the BSONDoc unit. Will dig further.

stijnsanders commented 9 years ago

You're right. OLE, Variants, Winsock are all heavily Windows-tied. Cross-platform support was not one of the goals for TMongoWire.

stijnsanders commented 9 years ago

Please have a look at the recent commit(s): I've replaced using Sockets.pas with simpleSock.pas which is a (very!) lightweight wrapper around only the essential bits of WinSock2. This should perform well in all versions of Delphi (and may lead a way to porting to other platforms)