1
votes

Existing scenario is explained below.

Our application is running on Client Server architecture; Client is developed with VC++ and Server is developed with C#.
On the Server side there are two exe's running (myServer1.exe -Windows service based, and myServer2.exe -Windows application). myServer2.exe is communicating to myServer1.exe through TCP socket connection.
On the Client side, an exe (myApp1.exe -Windows Service based) runs another exe based on user sessions present in the machine (myUser.exe for all user sessions). Every myUser.exe instances are communicating to myApp1.exe through PIPE communication. And myApp1.exe is also communicating to myServer1.exe through another TCP communication.

New scenario.

We are now creating a TCP socket in listening mode in myServer2.exe (Server application -C#). myUser.exe (Client application -VC++) is trying to connect to myServer2.exe through a TCP connection by using CAsyncSocket. But the framework calls (OnConnect, OnReceive and OnClose) are not happening.

Socket creation- Create(0,SOCK_STREAM); // CAyncSocket

Socket connection- Connect("ServerIP", "ServerPort"); // CAsyncSocket

Note: when we move the socket creation and connection functionalities into Windows service based exe (myApp1.exe), the connection works fine, OnConnect OnReceive and OnClose are happening.

Why framework call to OnConnect is not happening in myUser.exe while in myApp1.exe is?

1
so basically, you have a C# windows server application and many VC++ clients and you want them to communicate via TCP right? Share some codesalvolds
As of now the communication between the server and the clients are working fine. Problem is that I want to create a socket in the myUser.exe with sending mode and the myServer2.exe will be listening to the same.But the notification functions (Onconnect, OnSend etc) on the myUser.exe(VC++) is not happening. Always getting the socket error 10035 (The operation should be retired later). But we tried several times and still getting the same error. So the 'CAsyncSocket::Connect' always failing.Jithin Jose

1 Answers

0
votes

Your OnConnect method is not called because probably you don't have the message loop in myUser.exe while you have it in myApp.exe.

Error code 10035 is WSAEWOULDBLOCK and it' normal for your case, from MSDN:

It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.

So don't worry about it. If you have a message loop, after your Connect call, the OnConnect method will finally be called at a certain time with a successful result or with an error code.

See also codeproject and SO