日期:2014-05-17 浏览次数:20951 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BasicSocket.Client;
using System.IO;
using BasicSocket.Data;
using System.Globalization;
using System.Threading;
using System.Net;
namespace testclient
{
public class Connect
{
/// <summary>
/// 建立一个SOCKET客户端
/// </summary>
public static SocketClient[] client = new SocketClient[10000];
// This method will be called when the thread is started.
public void DoWork()
{
client[Program.count] = new SocketClient();
//client.DataOn += new DataOn(client_DataOn); //数据包进入事件
//client.Disconnection += new ExceptionDisconnection(client_Disconnection); //数据包断开事件
string hostip = "192.168.1.17";
string localip = Program.ipAddress + ":" + Convert.ToString(Program.count);
try
{
//if (client.ConnectionTo(hostip, 9982)) //使用同步连接到服务器,一步就用Begin开头的那个
if (client[Program.count].ConnectionTo(hostip, 9982)) //使用同步连接到服务器,一步就用Begin开头的那个
{
while (true)
{
//string localip = Console.ReadLine();
Thread.Sleep(90); //防止调用频繁访问冲突
&n