代码拉取完成,页面将自动刷新
/*****************************
* Author: YanNI
* Create:2018/3/7 14:27:55
* Email: admin@ircove.com
* QQ: 401608886
* TEl: 13520446271
****************************/
using System;
using System.Configuration;
using System.Net.Sockets;
using System.Threading;
namespace VFPush
{
public class Class1
{
static void Connect(String server, String message)
{
try
{
// Create a TcpClient.
// Note, for this client to work you need to have a TcpServer
// connected to the same address as specified by the server, port
// combination.
Int32 port = 13000;
TcpClient client = new TcpClient(server, port);
// Translate the passed message into ASCII and store it as a Byte array.
Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
// Get a client stream for reading and writing.
// Stream stream = client.GetStream();
NetworkStream stream = client.GetStream();
// Send the message to the connected TcpServer.
stream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", message);
// Receive the TcpServer.response.
// Buffer to store the response bytes.
data = new Byte[256];
// String to store the response ASCII representation.
String responseData = String.Empty;
// Read the first batch of the TcpServer response bytes.
Int32 bytes = stream.Read(data, 0, data.Length);
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
// Close everything.
stream.Close();
client.Close();
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: {0}", e);
}
catch (SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}
Console.WriteLine("\n Press Enter to continue...");
Console.Read();
}
public static void Main()
{
Console.WriteLine("ok");
string server = ConfigurationManager.AppSettings["vfpush_service"];
int port = Convert.ToInt32(ConfigurationManager.AppSettings["vfpush_port"]);
TcpClient client = new TcpClient();
client.NoDelay = true;
client.SendTimeout = 60 * 1000;
client.Connect(server, port);
NetworkStream stream = client.GetStream();
Thread thread = new Thread(x =>
{
int i = 100000;
byte[] btyes= new byte[1];
byte b = 65;
btyes[0] = b;
while (i>0)
{
i--;
try
{
stream.Write(btyes, 0, 1);
//Console.WriteLine(btyes[0]);
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}
Console.WriteLine("Rok");
});
Thread thread1 = new Thread(x =>
{
byte[] btyes = new byte[1];
int k = 100000;
while (k>0)
{
k--;
try
{
stream.Read(btyes, 0, 1);
Console.WriteLine(btyes[0]);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
Console.WriteLine("wok");
});
thread.Start();
thread1.Start();
Console.Read();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。