views:

257

answers:

1

Hello,

I've asked here a ton of questions about WSAAsyncSelect and NET.Few months ago I even spent 500 rep on a bounty and answered it myself(I made a wrapper).In the end I got used to the winsock in the framework.

Today I'm asking about unmanaged languages,the bad point is that I miss the framework way of doing things with sockets.I'm writing my project in Delphi,but I understand C-like languages so it'd be no problem and I'm not even asking for any code.I love natural things,so please don't suggest any components,pure code only. :)

People say it's good to create another hidden form and set the message loop there to properly use AsyncSelect.

Well,my question is simple:I placed the whole winsock functions i wrote to make my life easier inside that hidden form and also I set the WSaAsyncSelect with it's handle,the message loop is also there,but I've written child classes(many classes,huge code),the parent class is that hidden form.

Is WSAAsyncSelect thread-safe? Will this slow down things(what i've done with classes)?

Do I have to create threads outside the message loop?

Any other tips for using AsyncSelect properly will be greatfuly appreciated.

Edit: to avoid any misunderstanding,I'm asking directly about AsyncSelect().The project I work on requires 2 servers and 1 client,which I think,could be handled well with that call.

+1  A: 

People say it's good to create another hidden form and set the message loop there to properly use AsyncSelect.

Are you coding to WinSock directly, or using the VCL's TClientSocket and TServerSocket components? If the latter, then they already handle WSAAsyncSelect() internally for you (yes, they do use their own hidden window).

Is WSAAsyncSelect thread-safe?

Yes.

Will this slow down things(what i've done with classes)?

You have not actually explained what the classes are doing.

Do I have to create threads outside the message loop?

No, but sockets can be used by multiple threads if desired. However, the socket messages will only be processed by whatever thread owns the window that was passed to WSAAsyncSelect().

Remy Lebeau - TeamB
Thank you for your answer.One thing lasts.I use pure winsock with my sockets created by hand,no components.Could you show me how "sockets can be used by multiple threads if desired".
John