Click here to Skip to main content
15,894,825 members
Articles / Web Development / HTML

Asynchronous TCP Part 2

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
29 Mar 2013CPOL9 min read 41.3K   2.9K   30  
Goal: Describe how asynchronous or non-blocking TCP code works
#pragma once
#include "afxsock.h"

// take out per forum post here:  
// http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/thread/6048ebf5-e5d6-4ccc-9ca7-cc9dd98067df/
//#include "C_MFC_Winsock_01_Dlg.h"
#include "Constants.h"
#include "C_Server_Send_Time_Socket.h"

  // forward declare the main dialog here so we can declare a pointer to it without
  // includeing the dot H file.  See comment just above and forum reference.
class C_MFC_Winsock_01_Dlg;

class C_Server :
	public CAsyncSocket
{
public:
	C_Server(void);
	~C_Server(void);
   int  Class_Get_WSA_Error_Code();
	bool Class_Initialize();
	bool Class_Listen();
	bool Class_Accept();
	void Class_Close();
   int  Class_Send();

   void Set_Parent_Pointer( C_MFC_Winsock_01_Dlg *new_pointer );

public:
	void SetParentDlg(CDialog *pDlg);
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(C_Server_Send_Time_Socket)
	public:
	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 );
	//}}AFX_VIRTUAL

private:
	UINT m_port_number;
	int  m_wsa_error;
   bool m_method_status;
 	BOOL m_winsock_status;

   C_MFC_Winsock_01_Dlg *mp_main_dialog;

   unsigned int m_server_on_accept_count;
   unsigned int m_server_on_close_count;
   unsigned int m_server_on_connect_count;
   unsigned int m_server_on_out_of_band_count;
   unsigned int m_server_on_receive_count;
   unsigned int m_server_on_send_count;
   
	C_Server_Send_Time_Socket *mp_C_Server_Send_Time_Socket;

};

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)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions