惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
V
V2EX
博客园_首页
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
H
Help Net Security
A
About on SuperTechFans
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
云风的 BLOG
云风的 BLOG
D
Docker
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
N
News and Events Feed by Topic
Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
A
Arctic Wolf
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
aimingoo的专栏
aimingoo的专栏
Hacker News: Ask HN
Hacker News: Ask HN
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy International News Feed
T
Troy Hunt's Blog
T
Tenable Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Recorded Future
Recorded Future
F
Fortinet All Blogs
D
DataBreaches.Net
B
Blog
T
Threat Research - Cisco Blogs
MyScale Blog
MyScale Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
The GitHub Blog
The GitHub Blog
Security Latest
Security Latest
M
MIT News - Artificial intelligence

博客园 - Double_

一个开始----大数据思维模式在物联网系统运维应用的一个案例 轻松掌握ISO8583报文协议 在信息系统运维开发中,对MVC框架认识上的一种变通 [留着备用]ASP.NET动态菜单生成通用方法 福建省获得央行颁发的非金融机构支付业务许可牌照的公司(至2012-08-01) 替信息系统运维工作正名 工程上一例误差范围的计算方法(利用穷举法俗称笨方法又称愚公移山法还可称愚公大战智叟法) 至最近写的微博记录(一) 对古人“一命二运三风水,四积德五读书”的人生命运总结的理解 话说物联网 - Double_ - 博客园 SQL Server 2000实现一则按类似VB VAL函数功能排序的案例 SQL Server TEXT类型字段字符串替换示例处理脚本 获取SQL Server服务器的连接信息用脚本(在原邹建写的基础上作一点改进)与一段查询SQL Server服务器阻塞和死锁信息用的脚本 赖床狂想记录 字符串前部去除自定义函数(T-SQL) 复习:C#3.0面向对象测试开发包 M1非接触式射频存储卡卡唯一号(十六进制值表示),去除其前部为0的自定义函数 某储蓄卡业务系统若干问题求证与求解 从数据库系统管理的角度上回答数据库是什么
C#网络Socket的数据发送与接收处理(利用异步)的模板(模式)
Double_ · 2013-03-21 · via 博客园 - Double_

using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.Windows.Forms;

namespace SocketClient
{
    /// <summary>
    /// C#网络Socket的数据发送与接收处理(利用异步)的模板(模式)
    /// </summary>
    class test_Socket
    {
        Socket m_Socket;
        /// <summary>
        /// C#网络Socket的数据发送与接收处理(利用异步)
        /// </summary>
        /// <param name="_ip">要连接的IP</param>
        /// <param name="_Port">对方开放的端口</param>
        public void Net_Socket_Send_Receive(string _ip,int _Port)
        {
            IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(_ip), _Port);
            m_Socket=new Socket(ipep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            Byte[] buffer = new Byte[1024];
            m_Socket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(OnSend), null);
            byte[] recvBytes = new byte[20];
            m_Socket.BeginReceive(recvBytes, 0, recvBytes.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);

        }
        private void OnSend(IAsyncResult ar)
        {
            try
            {
                
                m_Socket.EndSend(ar);
            }
            catch (ObjectDisposedException)
            { }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Send: ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void OnReceive(IAsyncResult ar)
        {
            try
            {
                m_Socket.EndReceive(ar);

            }
            catch (ObjectDisposedException)
            { }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Receive: ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}