Beispiel #1
0
        private void frmClient_Load(object sender, EventArgs e)
        {
            try
            {
                // 加个委托显示msg,因为on系列都是在工作线程中调用的,ui不允许直接操作
                AddMsgDelegate = new ShowMsg(AddMsg);


                // 创建监听器对象
                pListener = HPSocketSdk.Create_HP_TcpClientListener();
                // 创建 Socket 对象
                pClient = HPSocketSdk.Create_HP_TcpClient(pListener);

                // 设置 Socket 监听器回调函数
                OnSendCallback    = new HPSocketSdk.HP_FN_OnSend(OnSend);
                OnConnectCallback = new HPSocket.HPSocketSdk.HP_FN_OnConnect(OnConnect);
                OnReceiveCallback = new HPSocketSdk.HP_FN_OnReceive(OnReceive);
                OnCloseOnClose    = new HPSocketSdk.HP_FN_OnClose(OnClose);
                OnErrorCallback   = new HPSocketSdk.HP_FN_OnError(OnError);

                // 设置 Socket 监听器回调函数
                HPSocketSdk.HP_Set_FN_Client_OnConnect(pListener, OnConnectCallback);
                HPSocketSdk.HP_Set_FN_Client_OnSend(pListener, OnSendCallback);
                HPSocketSdk.HP_Set_FN_Client_OnReceive(pListener, OnReceiveCallback);
                HPSocketSdk.HP_Set_FN_Client_OnClose(pListener, OnCloseOnClose);
                HPSocketSdk.HP_Set_FN_Client_OnError(pListener, OnErrorCallback);

                SetAppState(EnAppState.ST_STOPED);
            }
            catch (Exception ex)
            {
                AddMsg(ex.Message);
            }
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                this.Text = title;
                // 本机测试没必要改地址,有需求请注释或删除
                this.txtIpAddress.ReadOnly = true;

                // 加个委托显示msg,因为on系列都是在工作线程中调用的,ui不允许直接操作
                AddMsgDelegate = new ShowMsg(AddMsg);

                // 创建监听器对象
                pListener = HPSocketSdk.Create_HP_TcpServerListener();

                // 创建 Socket 对象
                pServer = HPSocketSdk.Create_HP_TcpServer(pListener);

                // 设置 Socket 监听器回调函数
                OnOnAcceptCallback       = new HPSocketSdk.HP_FN_OnAccept(OnAccept);
                OnSendCallback           = new HPSocketSdk.HP_FN_OnSend(OnSend);
                OnPrepareListenCallback  = new HPSocket.HPSocketSdk.HP_FN_OnPrepareListen(OnPrepareListen);
                OnReceiveCallback        = new HPSocketSdk.HP_FN_OnReceive(OnReceive);
                OnCloseCallback          = new HPSocketSdk.HP_FN_OnClose(OnClose);
                OnErrorCallback          = new HPSocketSdk.HP_FN_OnError(OnError);
                OnServerShutdownCallback = new HPSocketSdk.HP_FN_OnServerShutdown(OnServerShutdown);

                // 设置 Socket 监听器回调函数
                HPSocketSdk.HP_Set_FN_Server_OnPrepareListen(pListener, OnPrepareListenCallback);
                HPSocketSdk.HP_Set_FN_Server_OnAccept(pListener, OnOnAcceptCallback);
                HPSocketSdk.HP_Set_FN_Server_OnSend(pListener, OnSendCallback);
                HPSocketSdk.HP_Set_FN_Server_OnReceive(pListener, OnReceiveCallback);
                HPSocketSdk.HP_Set_FN_Server_OnClose(pListener, OnCloseCallback);
                HPSocketSdk.HP_Set_FN_Server_OnError(pListener, OnErrorCallback);
                HPSocketSdk.HP_Set_FN_Server_OnServerShutdown(pListener, OnServerShutdownCallback);

                SetAppState(EnAppState.ST_STOPED);
            }
            catch (Exception ex)
            {
                AddMsg(ex.Message);
            }
        }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                this.Text = title;
                // 本机测试没必要改地址,有需求请注释或删除
                this.txtIpAddress.ReadOnly = true;

                // 加个委托显示msg,因为on系列都是在工作线程中调用的,ui不允许直接操作
                AddMsgDelegate = new ShowMsg(AddMsg);

                // 创建监听器对象
                pListener = HPSocketSdk.Create_HP_TcpServerListener();

                // 创建 Socket 对象
                pServer = HPSocketSdk.Create_HP_TcpServer(pListener);

                // 设置 Socket 监听器回调函数
                OnOnAcceptCallback = new HPSocketSdk.HP_FN_OnAccept(OnAccept);
                OnSendCallback = new HPSocketSdk.HP_FN_OnSend(OnSend);
                OnPrepareListenCallback = new HPSocket.HPSocketSdk.HP_FN_OnPrepareListen(OnPrepareListen);
                OnReceiveCallback = new HPSocketSdk.HP_FN_OnReceive(OnReceive);
                OnCloseCallback = new HPSocketSdk.HP_FN_OnClose(OnClose);
                OnErrorCallback = new HPSocketSdk.HP_FN_OnError(OnError);
                OnServerShutdownCallback = new HPSocketSdk.HP_FN_OnServerShutdown(OnServerShutdown);

                // 设置 Socket 监听器回调函数
                HPSocketSdk.HP_Set_FN_Server_OnPrepareListen(pListener,OnPrepareListenCallback);
                HPSocketSdk.HP_Set_FN_Server_OnAccept(pListener, OnOnAcceptCallback);
                HPSocketSdk.HP_Set_FN_Server_OnSend(pListener,OnSendCallback );
                HPSocketSdk.HP_Set_FN_Server_OnReceive(pListener,OnReceiveCallback);
                HPSocketSdk.HP_Set_FN_Server_OnClose(pListener, OnCloseCallback);
                HPSocketSdk.HP_Set_FN_Server_OnError(pListener,OnErrorCallback);
                HPSocketSdk.HP_Set_FN_Server_OnServerShutdown(pListener, OnServerShutdownCallback);

                SetAppState(EnAppState.ST_STOPED);
            }
            catch (Exception ex)
            {
                AddMsg(ex.Message);
            }
        }
Beispiel #4
0
        private void frmClient_Load(object sender, EventArgs e)
        {
            try
            {
                // 加个委托显示msg,因为on系列都是在工作线程中调用的,ui不允许直接操作
                AddMsgDelegate = new ShowMsg(AddMsg);

                // 创建监听器对象
                pListener = HPSocketSdk.Create_HP_TcpClientListener();
                // 创建 Socket 对象
                pClient = HPSocketSdk.Create_HP_TcpClient(pListener);

                // 设置 Socket 监听器回调函数
                OnSendCallback = new HPSocketSdk.HP_FN_OnSend(OnSend);
                OnConnectCallback = new HPSocket.HPSocketSdk.HP_FN_OnConnect(OnConnect);
                OnReceiveCallback = new HPSocketSdk.HP_FN_OnReceive(OnReceive);
                OnCloseOnClose = new HPSocketSdk.HP_FN_OnClose(OnClose);
                OnErrorCallback = new HPSocketSdk.HP_FN_OnError(OnError);

                // 设置 Socket 监听器回调函数
                HPSocketSdk.HP_Set_FN_Client_OnConnect(pListener, OnConnectCallback);
                HPSocketSdk.HP_Set_FN_Client_OnSend(pListener, OnSendCallback);
                HPSocketSdk.HP_Set_FN_Client_OnReceive(pListener, OnReceiveCallback);
                HPSocketSdk.HP_Set_FN_Client_OnClose(pListener, OnCloseOnClose);
                HPSocketSdk.HP_Set_FN_Client_OnError(pListener, OnErrorCallback);

                SetAppState(EnAppState.ST_STOPED);
            }
            catch (Exception ex)
            {
                AddMsg(ex.Message);
            }
        }