易截截图软件、单文件、免安装、纯绿色、仅160KB

C#的TCP通信


TCP是连接模型,如下:
服务器连接                     服务器断开
    ↓                                   ↑
服务器接收→服务器处理→服务器发送
    ↑                                   ↓
客户端发送←客户端处理←客户端接收
    ↑                                   ↓
客户端连接                     客户端断开
服务器代码如下:
//
ServerListen
TcpListener tcplistener
=
new
 TcpListener(
int
.Parse(txtPort.Text));
tcplistener.Start();
byte
[] btServerReceive
=
new
 
byte
[
256
];
string
 strServerReceive
=
string
.Empty;
//
Loop for Listen
while
(
true
)
{
 TcpClient tcp
=
tcplistener.AcceptTcpClient();
 NetworkStream ns
=
tcp.GetStream();
 
int
 intReceiveLength
=
 ns.Read(btServerReceive,
0
,btServerReceive.Length);
 strServerReceive
=
UnicodeEncoding.Unicode.GetString(btServerReceive,
0
,intReceiveLength);
 txtServerResult.AppendText(
"
ServerReceive:
"
 
+
 strServerReceive
+
"

"
);
 ns.Write(btServerReceive,
0
,btServerReceive.Length);
 txtServerResult.AppendText(
"
ServerSend:
"
&


相关文档:

c# 操作excel

 OleDbConnection conn = null;
            try
            {
               `string strConn;
  &n ......

C#自动关机源码

源码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.IO;
using Microsoft.Win32;
namespace mv
{ ......

C# 回滚

 private void save_db(){
    SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings[""].ToString());
    SqlCommand comm = new SqlCommand();
    conn.Open();
    SqlTransaction rollbk2= conn.BeginTransaction();
& ......

c#简单操作注册表

一、首先先添加引用    using Microsoft.Win32;     
//因为操作注册表的两个类RegistryKey和Registry都包含在此引用中;
 
二、编写代码开始操作注册表
1、 #region      限制软件的使用次数
        pri ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号