Questions tagged [casyncsocket]

16 questions
7
votes
1 answer

When is it safe to close CAsyncSocket?

CAsyncSocket crashes my application if I delete the CAsyncSocket after a call to Connect, but before the OnConnect callback has been called. ASSERT(pSocket != NULL) fails in CAsyncSocket::DoCallBack and the application exits. In other words, if I…
morgancodes
  • 25,055
  • 38
  • 135
  • 187
5
votes
2 answers

What's behind the CAsyncSocket assertion problems and "improper argument" errors in my MFC sockets code?

I was asked to look at some code for a friend. (I rightly hesitated due to the MFC and lots of bad code, but he won...) This is a dialog box based application that uses a CAsyncSocket. The problem manifests in some nonstop debugbreaks and other…
Tim
  • 20,184
  • 24
  • 117
  • 214
1
vote
1 answer

Asyncsockets and "silent" disconnections

I've been using cocoaasyncsocket as a client to a Windows .net server using asyncsocket. I am encoding messages using ProtocolBuffers. Together, these make a great set of tools. However recently I have noticed that if I leave the client connected to…
hocker
  • 688
  • 6
  • 18
0
votes
0 answers

Selecting a socket interface for any unknown environment

Question background: My MFC CAsyncSocket-based socket code has worked fine in the lab for a long time, until it didn't (see how to determine socket interface type). It's design was based on the Microsoft Docs sample code which sequentially walks…
0
votes
1 answer

how to determine socket interface type

A little background for the question: I recently had a near-death experience with Microsoft and socket binding. I was testing production code and one of the test PCs kept failing. I eventually suggested that there was a bug in the bind() function,…
rtischer8277
  • 496
  • 6
  • 27
0
votes
1 answer

CAsyncSocket::OnReceive not being called in DLL

I have a Qt program that needs to use VC++ CAsyncSocket for TCP connection. I have created a dll. to wrap CAsyncSocket. class CClientSocket ; class __declspec(dllexport) CClientSocketEx { public: CClientSocketEx(); ~CClientSocketEx(); …
sriep
  • 21
  • 5
0
votes
0 answers

CAsyncSocket 10093 error

I inherited from CAsyncSocket, implement my own class. Firstly, it starts like: MyClient::MyClient()//this is the constructor, I will create the socket in this constructor { if (!Create(0, SOCK_DGRAM, FD_READ | FD_WRITE)) { UINT errCode =…
firstaccount
  • 155
  • 2
  • 13
0
votes
0 answers

CAsyncSocket Bind() fails when multiple IP addresses are configured in a PC out of network

I have a PC which has multiple IP addresses configured and which is out of network. I am trying to run a server software which is developed on VC++ using CAsyncSocket on this PC. But the Bind() function in this software always fails with an error…
sam
  • 101
  • 1
  • 6
0
votes
1 answer

Using std::packaged_task to queue CAsyncSocket-Detach-socket tasks causes compile error when non-static Attach is called from static method

I am implementing code so I can Accept network connections as they arrive, Detach them from their arrival socket, create an std::packaged_task task, queue that task in a deque container, and then execute those tasks in their task thread later.…
rtischer8277
  • 496
  • 6
  • 27
0
votes
1 answer

Using CAsynSocket, how to catch socket operations' exit code?

Please, someone kindly help me how to catch socket operation's error from CAsyncSocket Class. If I do this: int iLen = recv(socket, socketBuffer, sizeBuffer, 0); if(iLen==SOCKET_ERROR) { //handle error here } else { //do something with the…
Trung Nguyen
  • 177
  • 1
  • 12
0
votes
1 answer

Access a socket that has been passed to thread

I am new to MFC's CWinThread and CAsyncSocket, and trying to learn them myself with dialog based application. Here is what I want to do: make a server/multi-client model: when the number clients connect to server, the server will make threads…
Trung Nguyen
  • 177
  • 1
  • 12
0
votes
1 answer

C++ Stop CAsyncSocket splitting single large packet to multiple small packets

I'm writing a client that connects to a server Sometimes the server send dome special packets to the client with the size of 30kb but on client side I get that 30kb in multiple smaller packets (1kb) so my OnReceive callback calls almost 30 times…
Shahriyar
  • 1,483
  • 4
  • 24
  • 37
0
votes
1 answer

VC++ 6.0: Why is CASyncSocket::GetLastError() causing an access violation?

I'm using Visual C++ 6.0. I'm not sure of the service pack level of the visual studio installation, but the OS is Win 2K SP4. The failing code is part of a DLL. Here's the code: EIO::OpenConnection() { m_Client = new CSocket(); …
Andrew Spiehler
  • 209
  • 1
  • 2
  • 8
0
votes
0 answers

MFC Server/Client Timeout when on different computers

I have a client and server written with MFC using Winsock. They only work when they are on the same computer(i.e. "127.0.0.1") but once I attempt to connect the a client from a different computer I receive error code 10060 which is a TimeOut Error.…
user1704863
  • 394
  • 1
  • 6
  • 19
0
votes
1 answer

CAsyncSocket and thread / process safety

I have some legacy code using a CAsyncSocket derived class. This class overrides OnReceive and it also has a wrapper around SendTo. The code is in a dll which multiple applications will be using on the same PC, all ports are hard coded. I'm…
flobadob
  • 2,804
  • 2
  • 22
  • 23
1
2