|
|
|
@ -18,16 +18,15 @@ namespace formula_manage.UserClass |
|
|
|
//字典集合:存储IP和Socket的集合
|
|
|
|
public static Dictionary<string, Socket> OnLineList = new Dictionary<string, Socket>(); |
|
|
|
|
|
|
|
DataTable IPdataTable = new DataTable(); //建立缓存
|
|
|
|
//当前时间
|
|
|
|
|
|
|
|
|
|
|
|
//当前时间
|
|
|
|
private string CurrentTime |
|
|
|
{ |
|
|
|
get { return DateTime.Now.ToString("HH:mm:ss") + Environment.NewLine; } |
|
|
|
} |
|
|
|
|
|
|
|
//编码格式
|
|
|
|
public static Encoding econding = Encoding.Default; |
|
|
|
public static Encoding econding = Encoding.UTF8; |
|
|
|
|
|
|
|
public static void Start() |
|
|
|
{ |
|
|
|
@ -80,7 +79,7 @@ namespace formula_manage.UserClass |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
//定义一个2M的缓冲区
|
|
|
|
byte[] buffer = new byte[1024 * 1024 * 2]; |
|
|
|
byte[] buffer = new byte[1024 * 1024 * 10]; |
|
|
|
|
|
|
|
int length = -1; |
|
|
|
try |
|
|
|
@ -94,12 +93,10 @@ namespace formula_manage.UserClass |
|
|
|
string ip = clientSocket.RemoteEndPoint.ToString(); |
|
|
|
UserClass.LogGing.LogGingDATA("IP_Line = " + ip); |
|
|
|
// AddOnLine(ip, false);
|
|
|
|
OnLineList.Remove(ip); |
|
|
|
|
|
|
|
break; |
|
|
|
OnLineList.Remove(ip); //移除ip
|
|
|
|
break; //退出循环
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (length == 0) |
|
|
|
{ |
|
|
|
//客户端下线了
|
|
|
|
@ -108,11 +105,9 @@ namespace formula_manage.UserClass |
|
|
|
UserClass.LogGing.LogGingDATA("IP_Line = " + ip); |
|
|
|
// AddOnLine(ip, false);
|
|
|
|
OnLineList.Remove(ip); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (length > 0) |
|
|
|
else |
|
|
|
{ |
|
|
|
infoR = econding.GetString(buffer, 0, length); |
|
|
|
//ShowMessage(info);
|
|
|
|
|