Click here to Skip to main content
12,627,002 members (36,588 online)
Click here to Skip to main content

Stats

20.5K views
2.1K downloads
27 bookmarked
Posted

Asynchronous TCP Part 2

, 29 Mar 2013 CPOL
Goal: Describe how asynchronous or non-blocking TCP code works
#pragma once
#include "afxsock.h"
#include "Constants.h"

class C_MFC_Winsock_01_Dlg;

class C_Client :
	public CAsyncSocket
{
public:
	C_Client(void);
	~C_Client(void);

   void Set_Parent_Pointer( C_MFC_Winsock_01_Dlg *new_pointer );

	int  Class_Get_WSA_Error_Code();
	bool Class_Initialize();
	bool Class_Connect();
	bool Class_Close();
   bool Class_Receive();
   SYSTEMTIME Class_Get_Time();


	virtual void OnAccept(int nErrorCode);
	virtual void OnClose(int nErrorCode);
	virtual void OnConnect(int nErrorCode);
	virtual void OnOutOfBandData(int nErrorCode);
	virtual void OnReceive(int nErrorCode);
	virtual void OnSend(int nErrorCode);

private:

	TCHAR m_ip_address[ MAX_IP_ADDRESS_LENGTH ];
	UINT m_port_number;
	int  m_wsa_error;
   BOOL m_winsock_status;
   bool m_method_status;

   C_MFC_Winsock_01_Dlg *mp_main_dialog;
   SYSTEMTIME m_current_time;


   unsigned int m_client_on_accept_count;
   unsigned int m_client_on_close_count;
   unsigned int m_client_on_connect_count;
   unsigned int m_client_on_out_of_band_count;
   unsigned int m_client_on_receive_count;
   unsigned int m_client_on_send_count;

};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

bkelly13
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.3 | Last Updated 29 Mar 2013
Article Copyright 2012 by bkelly13
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid