Replies: 5 comments 11 replies
-
|
You probably already found the few examples at http://ararat.cz/synapse/doku.php/public:howto The old examples are still in some older clones of this github repo. For UDP you can also find several examples on the internet. Hope that's enough for you to get started 😉 |
Beta Was this translation helpful? Give feedback.
-
|
As I am experimenting with the synapse lib, I came across the following: I am sending data from the main/GUI thread in Lazarus currently. I observed the "blocking" when calling I tried using the I learned that I probably need to put the sending code in its own thread. I wonder tho, if I just extract the current code into a separate thread, will the sending delay be the same as I have observed? Where does that delay come from? What is the socket "waiting for" to send the data eventually? Since I am using a UDP connection, I do not await a response or even a confirmation that there is someone listening at the remote end (in fact, it does not influence the delay if I have the server app running or not). My expectation is that the sending should be done in no time, even if I am calling it from the main/GUI thread. Is that a misconception? Follow-up question I have in my head right now also is: If I create the sending thread, how do I "fill in" the data it has to send in a proper way? Do I need to have a queue for that? |
Beta Was this translation helpful? Give feedback.
-
|
I share my code stub here, maybe it is helpful for others: Preparation: Use the Project Inspector to add the "blcksock.pas" file from the synapse lib to your project. |
Beta Was this translation helpful? Give feedback.
-
|
I am trying to get a simple UDP-send-receive setup going, but it won't work and I am out of ideas.... There are just two sockets, one for There is one strange thing I observed: I tried setting a family (SF_IP4) use CreateSocket or not, use bind, or connect, put the listening socket into listen() mode or not, terminating the sending String with CRLF or not etc etc. (Note: The following code now contains the fixes suggested by geby in a later reply! Also freeing the sockets was added as gcarreno pointed out!) |
Beta Was this translation helpful? Give feedback.
-
|
Basic UDP usage idea is: client: server: listen or accept is for connection oriented sockets like TCP. UDP is datagram based. Any manipulations with remotesin not needed. Each call of RecvPacket sets Remotesin internally, and it is used by subsequent send operation. Do not use recvstring on UDP. It is designed to stream based sockets. Use RecvPacket instead - it receive one full datagram. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to use the lib in a Lazaraus/Freepascal project, but it is ultra hard to find an entry point or get a grasp of how complex this would turn out.
All the documentation I found was mainly a list of features. Or demos to examples like mail/smtp etc. that does not fit my use-case.
So my question is:
I would like to do a simple TCP or UDP state synchronization, say like in a game server. Clients connect, send some messages, the server should send appropriate messages to other clients. Maybe a chat function as an example starting point.
So, how you do it?
Which class to import into my project?
Where is the TTCP-/TUDP-Connection class?
I need a "Hello World with Synapse" kind of kickstart project, please!
TY!
Beta Was this translation helpful? Give feedback.
All reactions