摘要: 差不多有一个礼拜总算有点进步。代码很简单,只是为了实现功能。网络上的资源是很多,除了不能用的,就是抄来抄去,是在乏味浪费时间。说一下代码背景:实现的功能是发送端发送消息,接收端接收后立即响应,发送端接受响应的消息。类似心跳数据,超时后更换自己IP。 就是一个备份机上运行的程序,向主机发送心跳数据,如果主机挂了(接受超时),备份机更换自己IP为主机IP。接收端:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.... 阅读全文
posted @ 2013-10-15 23:40 Dufe王彬 阅读(681) 评论(0) 推荐(0) 编辑
摘要: C#UDP(接收和发送源码)源码完整最近做了一个UDP的服务接收和发送的东西。希望能对初学的朋友一点帮助。源码如下:一。逻辑--UdpServer.csusingSystem;usingSystem.Net;usingSystem.Net.Sockets;usingSystem.Threading;usingSystem.Diagnostics;usingSystem.Windows.Forms;usingSystem.Collections.Generic;usingSystem.Xml.Linq;usingPitchServer.po;namespacePitchServer.vo{cla 阅读全文
posted @ 2013-10-15 23:20 Dufe王彬 阅读(1421) 评论(0) 推荐(0) 编辑
摘要: C# codenamespace UDPServer{ class Program { static void Main(string[] args) { int recv; byte[] data = new byte[1024]; //构建TCP 服务器 //得到本机IP,设置TCP端口号 IPEndPoint ipep = new IPEndPoint(IPAddress.Any , 8001); Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram , ProtocolType.Udp); // 阅读全文
posted @ 2013-10-15 23:13 Dufe王彬 阅读(2633) 评论(0) 推荐(0) 编辑