Socket in NET

  • Thread starter Thread starter Jianxin
  • Start date Start date
J

Jianxin

Hi,

As I understand, one of the windows socket features is to
be able to connect to window message. As implemented in
CAsyncSocket class of MFC for example, OnReceive(),
OnAccept() etc. give you a handy way to deal with socket
events without using multithread.

I have just scaned through the Socket class in NET. But I
cannot see anything or anyway to do simillar things such
as OnReceive() OnAccept() in MFC.

Is there any way in which I can simillar thing in NET?

Thanks in advance.

Jainxin
 
Hi, Nicholas,

Thanks for your quick response. I think your suggestion
will do the job I have in mind.

After reading the NET doc, it seems to me that the
callback function provided in BeginXXX function will be
executed in a different thread from main window thread.
Is that right?

Jianxin

-----Original Message-----
Jianxin,

In .NET, you will want to use the BeginRecieve and EndReceive methods on
the Socket class to be notified when a socket gets data coming in.
Basically, the call to BeginReceive will cause the work to be done on
another thread and will notify your callback when the operation is complete.

Consequently, you can use the BeginAccept and EndAccept methods as well
to wait for an incoming connection.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jianxin said:
Hi,

As I understand, one of the windows socket features is to
be able to connect to window message. As implemented in
CAsyncSocket class of MFC for example, OnReceive(),
OnAccept() etc. give you a handy way to deal with socket
events without using multithread.

I have just scaned through the Socket class in NET. But I
cannot see anything or anyway to do simillar things such
as OnReceive() OnAccept() in MFC.

Is there any way in which I can simillar thing in NET?

Thanks in advance.

Jainxin


.
 
Back
Top