5

I'm just starting to get familiar with Embarcadero RAD Studio 2010 after living a life of Eclipse, Emacs, Visual Studio and notepad :)

I'm jumping into quite a large C++ application (500.000 - 1.000.000 lines) that I found made extensive use of TClientSocket and TServerSocket. The IDE first complanied about that TClientSocket was not found but could still compile and I scratched my head. Then I found out that it's not installed by default anymore and is marked as deprecated since way back.

I have tried to read about the subject but haven't found much information. My questions are

  • Why are TClientSocket and TServerSocket deprecated?
  • How do they differ in the way they function from WinSock and BSD sockets?
  • What would be best to use instead and is there a quick replacement that would not involve going through the entire application and changing everywhere TClientSocket and TServerSocket are being used? I would guess that it would mostly be the inner workings that have changed or?
M.M
  • 130,300
  • 18
  • 171
  • 314
inquam
  • 11,960
  • 14
  • 53
  • 95

2 Answers2

3

Deprecated because not supported any more. They are a wrap up of Winsock sockets, so the overall internal mechanism is the same - 'Create listener, listen, accept, create a client handler thread, passing it the ServerClientSocket, client thread reads and writes streams'.

You could maybe try just importing the components - if you have a massive legacy app to support, then this is surely the way to go if it works.

Then there's the other way :(( Use Indy or Synapse components to build 'TClientSocket' and TServerSocket' classes with identical members so that the legacy app will work without massive changes.

Kromster
  • 6,665
  • 7
  • 55
  • 98
Martin James
  • 23,610
  • 3
  • 33
  • 58
  • Yes, I have installed and imported the components so the application compiles and runs fine. But depending on the reason of the deprecation it might be and idea to create a wrapper class using indy or synapse – inquam May 27 '11 at 08:31
0

They have been deprecated in favour of Indy sockets.

However, Indy sockets are blocking-only. If your program used blocking sockets then this is fine, however if you are using non-blocking sockets, then as far as I am aware you only have two options:

  • use threads plus blocking Indy sockets
  • use TClientSocket and TServerSocket

There are components TTcpServer and TTcpClient which have a toggle between Blocking and Non-blocking. However, if you operate them in non-blocking mode, they just don't work (basic operations fail with WSAEWOULDBLOCK) and there is no workaround.

Note for anyone else reading this who may be unaware: even in the latest versions (as I write), you can still import them into the IDE by adding dclsocketsNNN.bpl into the list of design-time packages. They are there, just not active by default.

Personally I still use TClientSocket in non-blocking mode in production, it works just fine (after fixing some bugs, which is possible thanks to the fact that the full source is provided!)

M.M
  • 130,300
  • 18
  • 171
  • 314
  • Do you have these "fixes" available? Might solve some of the old strange bugs we sometimes see :) – inquam Jun 11 '14 at 10:01