#1 2024-07-24 14:12:40

Mo0211
Member
Registered: 2018-12-30
Posts: 24

Example TCP Socket connection with openssl

Hey all,

does anyone has an example code for a TCP Socket Connection with openssl?
I want to use either windows or linux - both should be possible.

Thanks for your help!

Offline

#2 2024-07-29 06:11:30

Mo0211
Member
Registered: 2018-12-30
Posts: 24

Re: Example TCP Socket connection with openssl

hey all,

i researched much over the weekend but i keep up my question and try to ask, if anyone has a working example for using TNetSocket.
This would be really great.

Thanks and have a great day

Offline

#3 2024-07-29 06:30:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,492
Website

Re: Example TCP Socket connection with openssl

Sorry for the delayed answer.

For TCP + TLS, the easiest is to use TCrtSocket.

On Windows, you need to define the USE_OPENSSL and FORCE_OPENSSL conditionals in YOUR project options to have this code actually link to the OpenSSL library from mormot.lib.openssl11.
Otherwise, it would use the system SChannel - which is likely to be enough for most simple cases, at least on a recent Windows version.

Offline

#4 2024-07-29 08:07:24

Mo0211
Member
Registered: 2018-12-30
Posts: 24

Re: Example TCP Socket connection with openssl

Hello Ab
,

thank you for your answer and no worries.
Do you know about any sample or project, where this is already used?
Sometimes it is easier to see how this can be implemented instead of guessing what should be the right approach.
The Chat-programm in the examples is different as i can see.

Offline

#5 2024-07-29 13:01:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,492
Website

Re: Example TCP Socket connection with openssl

You have a sample of using TCrtSocket with optional TLS support in mormot.net.client.

Just look at the SendEmail() function.
Note that you are not required to use SockIn or SockOut: if you know the size of your frames, you can just use direct access to the socket, e.g. SockInPending() or SockSend/SockSendFlush.

Offline

Board footer

Powered by FluxBB