FAQ:
Version of FAQ: 1.7.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.
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.
And IMHO Synapse is much better with nearly 100% kompatibility between Windows and Linux platform. Indy have lot of problems in Linux platform!
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?
See to DEMOS in distribute package. ECHO server is good sample for you!
Because this demo uses standard port 8 fpr echo. but Linux systems ussualy have their echo server at this port. Suimply change source of Demo for use another port instead 'echo'. (i.e. 2000).
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; buf := sock.RecvPacket(1000); if sock.lasterror=0 then begin // do something with data and prepare response data sock.SendString(Buf); end; sleep(1); end; sock.CloseSocket; finally sock.free; end; end;
Under windows you may install some Winsock wrapper with this support. Try Hummingbird or NEC.
But latest releases of Synapse have full native support for SOCKS5 in library code. Simply you fill adequate properties and this is all! Not need any external libraries, etc.
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.
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!
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!)
Check documentation and demo subdirectory in distribute packages. You may also check contributed download area.
If you not found demo in DEMo subdirectory in synapse.zip, try to search contributed download.
Look to main page of Synapse's WEB. Between download links you can find ling to directory with contributed downloads.
Check MPL license... generally: Yes, you may use Synapse in all your projects, you must only respects my coporights. For details check license file.
Yes. You need OpenSSL library at least version 0.9.6c. Interface between OpenSSL and Synapse is created in unit SynaSSL.pas. OpenSSL is loaded to memory only on demand. If you not need SSL/TLS mode, then you not need OpenSSL!
For simply use of SSL mode is prepared lot of methods in TCP code.
HTTP protocol implementation is SSL ready... simply use 'https' in URL.
IMAP, SMTP or POP3 protocols now support SSL too.
Is impossible bind one socket to more then one IP. Indy virtually can do it, but this is only illusions. Indy create one socket for each binded interface! If you need this, simply create one socket for each IP by your hands.
Direct test is impossible. Determining if connection still alive you can do only at moment of communicating. If you try send or receive data on broken TCP channel, then error is returned. It is only one way to determine broken TCP channel!
If Connection is closed gracefuly, then CanRead is signalised, but read operation read 0 bytes.
Yes, other packages have property 'active', but true value of this property is determined previous principes. It is not direct determine of live TCP conection. It is faked value!
There is no any event for reading data. Synapse have another reading design!
Other asynchronous packages have event, what is called if some data arraived. You must implement this event, read all data to your buffers, and then your application logic must parse this data.
In Synapse is another logic used. There is no any event! All data is readed at moment when your application logic need data. Simply you implement your application logic in style: "I need send data, simply call command for send. I need receive some data, simply call command for receive this data."
(respond by Nikolay Buhalov shaman@lotofsoftware.com)
1. Needed to generate header files (hpp) for including in project (example for creatinh header file for dnssend.pas):
DCC32.EXE -JPHW DNSSEND.PAS
2. Need to define path of .pas files:
Project->Add->Directories/Conditionals add in "Include path", "Library path" and "Debug source path" next string:
"$(BCB)\synapse\source\lib"
3. Define path to .pas files in BCB enviroment variables:
Tools -> Environment Options ->Library "Library path" and "Browsing path".
including library to project:
Project -> Add to project -> DNSSEND.PAS (for example)
including header file:
unit1.h
------------------------
#include
------------------------
unit1.cpp
-------------------------
#pragma link "DNSsend"
-------------------------
Possible, error can appear in string 180 of file blcksock.hpp:
__property WSAData WSAData = {read=FWsaData};
I' just comment this string cause i don't need to use this variable:
// __property WSAData WSAData = {read=FWsaData};
This is one example of using multicasts from SynaList:
Description:
10.0.0.5 is a network adapter on the local machine
224.1.0.1/22401 is any class D IP address + port
procedure multicasttest; var sndsock:TUDPBlockSocket; rcvsock:TUDPBlockSocket; buf:string; begin sndsock:=TUDPBlockSocket.Create; rcvsock:=TUDPBlockSocket.Create; try sndsock.createsocket; sndsock.connect('10.0.0.5','22401'); sndsock.AddMulticast('224.1.0.1'); if sndsock.LastError<>0 then exit; rcvsock.createsocket; rcvsock.bind('10.0.0.5','22401'); rcvsock.AddMulticast('224.1.0.1'); if rcvsock.LastError<>0 then exit; if sndsock.LastError=0 then sndsock.SendString('Test Payload'); buf:=rcvsock.RecvPacket(1000); showmessage(buf); sleep(1); sndsock.CloseSocket; rcvsock.CloseSocket; finally sndsock.free; rcvsock.free; end; end;