Synapse
Synchronous TCP/IP Library for Delphi

FAQ:

Version of FAQ: 1.2.0

    The FAQ is created based on your questions. If you do not ask questions, nothing will appear here. So please ask when facing any trouble, I will reply.


Why Synapse instead Indy?

   Indy is very large and complex set of complicated classes. In many cases, you need simple thinks. Why use very large Indy? Use small Synapse! Synapse is very simple and maximal versatile.

   In my opinion, Indy and Synapse is for different purpose. This is reason, why i develop Synapase. This is reason, why I helping to Indy.


How can I install Synapse components?

   Synapse is NOT components. It is only library units with code and classes. It cannot install, it not need install! For using synapse you can copy all neccessary Synapse units to your project directory (or to your library search path) and in your project add USES line with refference to needed Synapse units.

   Non-component concept is very good for writing non-visual application, i.e. NT services, CGI programs, Command-line program. You may use synapse in visual program too. It is easy!

   TCP/IP communication cannot be visualised, why use components?


How can I write TCP server?

   See to DEMOS in distribute package. ECHO server is good sample for you!


How can I write UDP server?

   Try next code on thread, or in any other case:

procedure TSomeThread.Execute;
var
  Sock:TUDPBlockSocket;
  size:integer;
  buf:string;
begin
  Sock:=TUDPBlockSocket.Create;
  try
    sock.createsocket;
    sock.bind('0.0.0.0','port');
    if sock.LastError<>0 then exit;
    while True do
      begin
        if terminated then break;
        if sock.canread(1000) then
          begin
            size:=sock.WaitingData;
            if size>0 then
              begin
                setlength(buf,size);
                sock.RecvBufferFrom(pointer(Buf),Size);
  //            do something with data and prepare response data
                sock.SendBufferTo(pointer(Buf),length(buf));
              end;
          end;
        sleep(1);
      end;
    sock.CloseSocket;
  finally
    sock.free;
  end;
end;

How can I use SOCKS5 proxy?

    You must install some Winsock wrapper with this support. Try Hummingbird or NEC.


I need SOCKS5 support only for my application.

    One way is: grab from installed HummingBird SOCKS5 client this files: WSOCK32o.DLL, HUMPRDSK.DLL, WSOCK32.DLL and SOCKS.CNF. Rename ile WSOCK32.DLL to another name, i.e. HMS32.DLL. All this files copy to directory with your application. In your application use in TTCPBlockSocket or TUDPBlockSocket constructor CreateAlternate('HMS32.DLL') instead Create constructor. It's all. ;-)


Do Synapse all exactly same under Windows and Linux?

    Yes! Only one small exception is loading alternate socket stack. Only under windows you may select what DLL is used for calling Winsock. Under linux is called Libc in all cases. All other thinks is same under both operating systems, include autodetection time zones or autodetection of charset used by system.


Why I get negative numbers instead large integer numbers in some cases?

    Because lot of internet protocols use unsigned 32-bit integers type. But Delphi Integer type is signed! 31-bits used for value, last bit is sign. If I load 32-bit unsigned integer to Delphi Integer type, last 32-th bit is loades to sign. This is reason why large internet integer looks like negative numbers.

    Nevertheless this negative number is same value as 32-bit internet integer! Different is only representation of this number. If you try convert this negative number to HEX, (or other format), you get correct value. If you try typecast this negative value to larger integer type (i.e. int64), you get good value!

    Negative values is not bug, it is only different representation of same value of large number!


Why you not use Int64 type for large integers?

    Because older Delphi does not have this 64-bit integer type! But Synapse is compatible with Delphi version 2.0 and 3.0 too. Cardinal type is not solution, because in this older delphi versions is cardinal only 31-bits integer. (It is terrible!)