日期:2014-05-17 浏览次数:20862 次
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;
namespace testclient
{
public class Connect
{
/// <summary>
/// 建立一个SOCKET客户端
/// </summary>
public static SocketClient client = new SocketClient();
// This method will be called when the thread is started.
public void DoWork()
{
//client.DataOn += new DataOn(client_DataOn); //数据包进入事件
//client.Disconnection += new ExceptionDisconnection(client_Disconnection); //数据包断开事件
string hostip = "127.0.0.1";
string localip = Convert.ToString(Program.count);
//if (client.ConnectionTo(hostip, 9982)) //使用同步连接到服务器,一步就用Begin开头的那个
if (client.ConnectionTo(hostip, 9982)) //使用同步连接到服务器,一步就用Begin开头的那个
{
while (true)
{
//string localip = Console.ReadLine();
Thread.Sleep(1000); //防止调用频繁访问冲突
SendDataClass.PPo temp = new SendDataClass.PPo();
temp.RealWeight = 14.5;