473,473 Members | 4,204 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Managed C++ - Asynchronous Socket Comm - AsyncCallback

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)
Nov 23 '06 #1
1 6667
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".

--
Nov 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Niels Johansen | last post by:
Hello, When using the asynchronous read method in the BufferedStream class, , it seems to me that it blocks like the normal synchronous read method. Why is it so? Why does the...
7
by: Colin | last post by:
I'm writing a little console socket server but I'm having some difficulty. Can I ask your advice - where is the best place to get some help on that topic? It would be nice if some people who knew...
1
by: Assaf Shemesh | last post by:
Hi, I'm having a problem with asynchronous HttpWebRequest. It's a simple http client-server. For most of my users it works fine. However, some of them get the exception: ...
2
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless...
0
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a...
4
by: Engineerik | last post by:
I am trying to create a socket server which will listen for connections from multiple clients and call subroutines in a Fortran DLL and pass the results back to the client. The asynchronous socket...
9
by: darthghandi | last post by:
I am trying to create a server application using asynchronous sockets. I run into a problem when I try to connect to my server using a non-.net program. I can establish the connection, and send...
0
by: cmrhema | last post by:
Hi, We have an asynchronous server socket program, which works fine BUT, when due to some circumstances, I receive null data or blank data, the server goes to infinite loop Here is the code ...
1
by: keksy | last post by:
Hi every1, I am writing a small client/server application and in it I want to send an image asynchronous from the client to the server through a TCP socket. I found an example code on the MSDN...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.