Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Managed C++ - Asynchronous Socket Comm - AsyncCallback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alper AKCAYOZ - 23 Nov 2006 15:07 GMT
Hello,

I have developped asynchronous socket communication with blocking Socket
commands (accept, connect, send, receive) by using threads on Windows .NET
Forms. It is working properly. Now I want to code the similar program with
Asynchronous Socket commands of .NET using Managed C++ on Windows .NET Forms.
My problem is with delegates. I have to use "static" methods as parameter
in delegate constructor like below:
-----------------------------------------------
static Socket* ServerSocket ;
void Listen()  {
   ...
   ServerSocket ->BeginAccept(new AsyncCallback( 0,
&frmAsySERVER::AcceptCallback), ServerSocket );
  ...  
}

static void AcceptCallback(IAsyncResult* ar) {
    ...
    Socket* listener = __try_cast<Socket*>(ar->AsyncState);
    ServerSocket = listener->EndAccept(ar);
   
    StateObject* state = new StateObject();
    state->workSocket = ServerSocket;
    ServerSocket->BeginReceive(state->buffer,
                                              0,
                                              StateObject::BufferSize,
                                              SocketFlags::None,
                                       new AsyncCallback(0,
&frmAsySERVER::ReadCallback),
                                              state);
}
--------------------------------------------

My problem is at the Asynchronous Socket Commands' callbacks. Is "static
void AcceptCallback(IAsyncResult* ar)" is not "static, I cannot call it from
"ServerSocket ->BeginAccept(new AsyncCallback( 0,
&frmAsySERVER::AcceptCallback), ServerSocket );" .
Isn't there any AsyncCallback constructor creation as easy as in C#.
Managed C++ -> "new AsyncCallback( 0, &frmAsySERVER::AcceptCallback)"
C# -> new AsyncCallback( AcceptCallback)

I cannot write some information onto listboxes , textboxes , labels on the
Windows .NET Forms from the "static" functions, unless they are not "static".

~~~~~~~~~~~~~~~~~~~
İyi Çalışmalar
Alper AKÇAYÖZ (Bil Muh)

Wish You Good Work
Alper AKCAYOZ (Bil Muh)
Alper AKCAYOZ - 23 Nov 2006 15:11 GMT
CORRECTION

My problem is at the Asynchronous Socket Commands' callbacks. IF "static
void AcceptCallback(IAsyncResult* ar)" is not "static, I cannot call it from
"ServerSocket ->BeginAccept(new AsyncCallback( 0,
&frmAsySERVER::AcceptCallback), ServerSocket );" .
Isn't there any AsyncCallback constructor creation as easy as in C#.
Managed C++ -> "new AsyncCallback( 0, &frmAsySERVER::AcceptCallback)"
C# -> new AsyncCallback( AcceptCallback)

I cannot write some information onto listboxes , textboxes , labels on the
Windows .NET Forms from the "static" functions, unless they are not "static".

--

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.