Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Asynchronous winsock sockets

winsock mfc

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 KansaiRobot

KansaiRobot

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 82 posts

Posted 31 August 2016 - 09:01 PM

Hello

I am now preparing to write a program using Winsock and I have several questions. Would appreciate some guidance.

First. I know there are synchronous(blocking) and asynchronous sockets. 
I can see the usefulness of asynchronous sockets in a server program that waits for incoming connections. If not used, the blocking socket will ,...well "block" the program until a connection comes.

But what about a client program. Why would it need an asynchronous socket??

At first I though... well if it uses a GUI, it will be good to use that so as to not to block the GUI parts such as buttons and stuff, but then thinking about it... will a blocking socket "block" anything? because a client program sill connect , send and receive things and not wait right???

unless, this connecting sending and receiving takes time... does it??

my second question is ... if I want to use CAsyncSocket , does this work only with MFC C++ programs?? 
I mean , can't I -say- build as C++ CLI program and use that?? so far I have gotten some sample programs that use MFC -but I dont like MFC frankly- so I am wondering if that is a requirement.

Thanks for any help



#2 zika

zika

    CC Regular

  • Member
  • PipPipPip
  • 26 posts

Posted 05 September 2016 - 09:00 PM

At first I though... well if it uses a GUI, it will be good to use that so as to not to block the GUI parts such as buttons and stuff, but then thinking about it... will a blocking socket "block" anything? because a client program sill connect , send and receive things and not wait right???

unless, this connecting sending and receiving takes time... does it??

 

 

--------

U can use CreateThread or _beginthreadex to make it multithread and avoid blocking Gui ... make every function in separate thread .