test.cs
来源:互联网 发布:企业海关出口数据查询 编辑:程序博客网 时间:2024/05/19 07:42
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Ports;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Globalization;
using Microsoft.Win32;
namespace ConsoleApplication2
{
class Program
{
[DllImport("kernel32.dll")]
static extern uint GetTickCount();
[DllImport("user32")]
static extern void MessageBeep(int type);
static void Main(string[] args)
{
byte[] btarry = new byte[10];
btarry[0] = 0x02;
string tempstr = new ASCIIEncoding().GetString(btarry, 0, 1);
Console.WriteLine(tempstr);
//string ComputerName = Dns.GetHostName();
//IPHostEntry myHost = new IPHostEntry();
//myHost = Dns.Resolve(ComputerName);
//for (int i =0; i < myHost.AddressList.Length; i++)
//{
// Console.WriteLine("{0}", myHost.AddressList[i].ToString());
//}
try
{
//int port = 3355;
//string host = "192.168.0.23";
string host = args[0];
int port = Convert.ToInt32(args[1]);
IPAddress ip = IPAddress.Parse(host);
IPEndPoint ipe = new IPEndPoint(ip, port);
Socket c = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
c.Connect(ipe);
string sendStr = string.Empty;
bool b = true;
ulong t = GetTickCount();
ulong t1 = t;
ulong d = 10 * 1000;
while (true)
{
if (b)
{
sendStr = tempstr + "10 0 0";
}
else
{
sendStr = tempstr + "10 58960 0";
}
byte[] bs = Encoding.ASCII.GetBytes(sendStr);
c.Send(bs, bs.Length, 0);
Console.WriteLine(sendStr);
byte[] recvBytes = new byte[1024];
System.Threading.Thread.Sleep(1000);
t1 = GetTickCount();
if (t1-t >d)
{
t = t1;
b = !b;
}
}
c.Close();
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: {0}", e);
}
catch (SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}
Console.ReadLine();
}
}
}
- test.cs
- c# hello world csc test.cs
- GRE Subject Test Computer Science (GRE Sub CS) 考试经验
- CS..........................
- cs
- cs
- cs
- Cs
- cs
- cs
- cs
- CS
- cs
- cs,
- cs
- cs
- cs
- cs
- LibT800Data.cs
- IObjectSafety.cs
- Hello.resx
- Hello.Designer.cs
- Hello.cs
- test.cs
- Default.aspx
- initrd的缺点和initramfs的优点
- 学习设计模式之状态模式
- Linux2.6 内核的 Initrd 机制解析
- 简单分数类
- 同情易找,帮助难寻!
- C笔试题(判断大端小端模式)
- #ifndef #define #endif用法