资源简介
像指定的IP和端口发送数据,发送完后并等待数据返回。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Net;
using System.Threading;
using System.IO;
namespace 向指定ip发送数据接收
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/**/
/* 在使用MySql时会遇到中文乱码的问题就此写下面两个函数
* 在写入数据库和从数据库读出时将编码改变
* author:alice
* date :2006/1/25
*/
//写入数据库时进行转换
public string GB2312_ISO8859(string write)
{
//声明字符集
System.Text.Encoding iso8859 gb2312;
//iso8859
iso8859 = System.Text.Encoding.GetEncoding(“utf-8“);
//国标2312
gb2312 = System.Text.Encoding.GetEncoding(“gb2312“);
byte[] gb;
gb = gb2312.GetBytes(write);
//返回转换后的字符
return iso8859.GetString(gb);
}
//读出时进行转换
public string ISO8859_GB2312(string read)
{
//声明字符集
System.Text.Encoding iso8859 gb2312;
//iso8859
iso8859 = System.Text.Encoding.GetEncoding(“utf-8“);//iso8859-1
//国标2312
gb2312 = System.Text.Encoding.GetEncoding(“gb2312“);
byte[] iso;
iso = iso8859.GetBytes(read);
//返回转换后的字符
return gb2312.GetString(iso);
}
static Socket clientSocket;
private void button1_Click(object sender EventArgs e)
{
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(“109.251.14.178“) 7159); //填写自己电脑的IP或者其他电脑的IP,如果是其他电脑IP的话需将ConsoleApplication_socketServer工程放在对应的电脑上。
clientSocket = new Socket(ipep.AddressFamily SocketType.Stream ProtocolType.Tcp);
//将Socket连接到服务器
try
{
//clientSocket.Connect(ipep);
String outBufferStr;
Byte[] outBuffer = new Byte[1024];
Byte[] inBuffer = new Byte[256];
//按照文本文件读取xml
System.IO.StreamReader myFile = new System.IO.StreamReader(Application.StartupPath + @“\CheckId.xml“ System.Text.Encoding.Default);
outBufferStr = myFile.ReadToEnd();
myFile.Close();
string strUTF8 = GB2312_ISO8859(outBufferStr);
string strGB = ISO8859_GB2312(outBufferStr);
string strUTF82 = GB2312_ISO8859(strGB);
//发送消息
//outBufferStr = “1234567890987654321“;//Console.ReadLine();
outBuffer = Encoding.Default.GetBytes(outBufferStr);
FileStream fs = new FileStream(Application.StartupPath + @“\CheckIdRet3.xml“ FileMode.Create);
StreamWri
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-09-17 23:15 向指定ip发送数据接收\
目录 0 2012-09-19 21:19 向指定ip发送数据接收\向指定ip发送数据接收\
文件 976 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收.sln
文件 15360 2012-11-19 15:15 向指定ip发送数据接收\向指定ip发送数据接收.suo
目录 0 2012-09-17 23:15 向指定ip发送数据接收\向指定ip发送数据接收\bin\
目录 0 2012-09-19 21:19 向指定ip发送数据接收\向指定ip发送数据接收\bin\Debug\
文件 481 2012-09-11 10:57 向指定ip发送数据接收\向指定ip发送数据接收\bin\Debug\CheckId.xm
文件 36230 2012-09-18 18:02 向指定ip发送数据接收\向指定ip发送数据接收\bin\Debug\CheckIdRet.xm
文件 0 2012-09-18 18:06 向指定ip发送数据接收\向指定ip发送数据接收\bin\Debug\CheckIdRet2.xm
文件 20480 2012-09-19 20:55 向指定ip发送数据接收\向指定ip发送数据接收\bin\Debug\向指定ip发送数据接收.exe
文件 26112 2012-09-19 20:55 向指定ip发送数据接收\向指定ip发送数据接收\bin\Debug\向指定ip发送数据接收.pdb
文件 5632 2005-11-11 22:25 向指定ip发送数据接收\向指定ip发送数据接收\bin\Debug\向指定ip发送数据接收.vshost.exe
文件 6942 2012-09-19 21:19 向指定ip发送数据接收\向指定ip发送数据接收\Form1.cs
文件 2042 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收\Form1.Designer.cs
文件 5814 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收\Form1.resx
目录 0 2012-09-17 23:15 向指定ip发送数据接收\向指定ip发送数据接收\obj\
目录 0 2012-09-19 20:55 向指定ip发送数据接收\向指定ip发送数据接收\obj\Debug\
目录 0 2012-09-17 23:15 向指定ip发送数据接收\向指定ip发送数据接收\obj\Debug\TempPE\
文件 842 2012-09-19 20:47 向指定ip发送数据接收\向指定ip发送数据接收\obj\Debug\向指定ip发送数据接收.csproj.GenerateResource.Cache
文件 20480 2012-09-19 20:55 向指定ip发送数据接收\向指定ip发送数据接收\obj\Debug\向指定ip发送数据接收.exe
文件 180 2012-09-19 20:47 向指定ip发送数据接收\向指定ip发送数据接收\obj\Debug\向指定ip发送数据接收.Form1.resources
文件 26112 2012-09-19 20:55 向指定ip发送数据接收\向指定ip发送数据接收\obj\Debug\向指定ip发送数据接收.pdb
文件 180 2012-09-19 20:47 向指定ip发送数据接收\向指定ip发送数据接收\obj\Debug\向指定ip发送数据接收.Properties.Resources.resources
文件 2332 2012-11-19 15:08 向指定ip发送数据接收\向指定ip发送数据接收\obj\向指定ip发送数据接收.csproj.FileListAbsolute.txt
文件 488 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收\Program.cs
目录 0 2012-09-17 23:15 向指定ip发送数据接收\向指定ip发送数据接收\Properties\
文件 1216 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收\Properties\AssemblyInfo.cs
文件 2914 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收\Properties\Resources.Designer.cs
文件 5612 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收\Properties\Resources.resx
文件 1114 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收\Properties\Settings.Designer.cs
文件 249 2012-09-17 21:05 向指定ip发送数据接收\向指定ip发送数据接收\Properties\Settings.settings
............此处省略1个文件信息
- 上一篇:实现字符串异或操作
- 下一篇:Flash拼图游戏源代码
相关资源
- stm32f407上的两个can发送和接收例程
- WPF USB 网络 串口 通信软件
- 用python编写的移动彩信的发送程序
- B/S 网上订餐系统
- 通信软件的具体实例──基于Socket的
- 向SysListView32里的某一行发送双击消息
- 教室管理系统.rar
- 用Socket编程实现FTP
- 38k单片机红外发送代码、keil
- 小鸡快跑游戏.
- websocket实现一对一聊天
- GPRS(MC35型号)的发送短信程序
- 51单片机读取温度数据存储到SD卡中并
-
分别适用于.NET fr
amework 2.0和4.0的E - 汽车租赁系统............................
- 德卡D8读写器关于读写感应卡的一些代
- halcon 测量助手
- 代码客:G-TcpServer(IOCP) 1.0 正式版及
- 图片存储到数据库保存二进制文件并
- SOCKET 网络编程 计算机网络 作业 客户
- linux 网络实验 ftp程序
- 用Socket写的简易FTP服务器和客户端
- 企业销售管理信息系统(全套)
- socket小工具(可方便建立TCP UDP的soc
- UDP组播的发送和接收程序
- 串口操作类(justinio)
- socket客户端源码
- 基于Petri网的工作流(完整的原创源代
- 选择题自动考试系统
- 多线程实例:桌面智能弹球小游戏
评论
共有 条评论