Board index » delphi » Indy Blocking TCP Sockets

Indy Blocking TCP Sockets

I have a very simple question concerning blocking sockets with Indy.  If a TIdTCPServer is blocked on a read in a thread, is it possible to write to the socket from the main thread?

Thank you.

Ian.

 

Re:Indy Blocking TCP Sockets


"Ian Davies" <i...@nospam.com> schrieb im Newsbeitrag
news:3ddceab6$1@newsgroups.borland.com...

Quote

> I have a very simple question concerning blocking sockets with Indy.  If a

TIdTCPServer is blocked on a read in a thread, is it possible to write to
the socket from the main thread?

Quote

Yes.
Parallel read and write operations are possible.

Andy

Re:Indy Blocking TCP Sockets


Thank you.  This is very interesting....

Ian.

Quote
"Andy M." <1...@123.com> wrote:

>"Ian Davies" <i...@nospam.com> schrieb im Newsbeitrag
>news:3ddceab6$1@newsgroups.borland.com...

>> I have a very simple question concerning blocking sockets with Indy.  If a
>TIdTCPServer is blocked on a read in a thread, is it possible to write to
>the socket from the main thread?

>Yes.
>Parallel read and write operations are possible.

>Andy

Re:Indy Blocking TCP Sockets


Quote
Ian Davies <i...@nospam.com> wrote in message

news:3ddd2eb0$2@newsgroups.borland.com...

Quote

> Thank you.  This is very interesting....

Andy is right, but one little note - if you intend to write from the
main thread and the 'read thread', (perhaps you send an 'ack', or
echo, or 'keepAlive'), then you need a critical section around the
'write' calls, to prevent the main & read threads writing
'simultaneously'.

Rgds,
Martin

Re:Indy Blocking TCP Sockets


Thanks Martin.  I think I should be OK without a critical section as the reading is done entirely by the thread and the only writing that occurs is from the main thread, i.e. the main and the read thread perform different operations.

Thanks,

Ian.

Quote
"Martin James" <mjames_fal...@dial.pipex.com> wrote:

>Ian Davies <i...@nospam.com> wrote in message
>news:3ddd2eb0$2@newsgroups.borland.com...

>> Thank you.  This is very interesting....

>Andy is right, but one little note - if you intend to write from the
>main thread and the 'read thread', (perhaps you send an 'ack', or
>echo, or 'keepAlive'), then you need a critical section around the
>'write' calls, to prevent the main & read threads writing
>'simultaneously'.

>Rgds,
>Martin

Other Threads