前段時間做了一個168的sp接口,share代碼,用socket實現d.

using  System;
using  System.Collections;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Text;
using  System.Windows.Forms;
using  System.Net;
using  System.Net.Sockets;
using  System.Threading;
using  System.IO;
using  System.Configuration;

namespace  SocketSever
{
    
public partial class MainForm : Form
    
{
        
业务操作

        
窗体操作

        
控件设定

        
投票操作
    }

}

 以上代碼是主程序用到的.由于這個東東在運行所以有些信息不便透露.

下面是其他的類.

using  System;
using  System.Data;
using  System.Configuration;
using  System.Net;
using  System.Net.Sockets;
using  System.Text;
namespace  SocketSever
{
    
/// <summary>
    
/// 套接字状态类
    
/// </summary>

    public class StateObj
    
{
        
/// <summary>
        
/// 套接字对象
        
/// </summary>

        public Socket WorkSocket = null;

        
/// <summary>
        
/// 套接字内存大小
        
/// </summary>

        public int bufferSize = 1024;

        
/// <summary>
        
/// 套接字内存字节数组
        
/// </summary>

        public byte[] buffer = new byte[1024];

        
/// <summary>
        
/// 套接字接受到的信息
        
/// </summary>

        public StringBuilder sb = new StringBuilder();
    }

}

 

這個是管理狀態的.

下面這個是處理業務的

 

using  System;
using  System.Collections.Generic;
using  System.Text;
using  System.Collections;
using  SocketSever.DLL;

namespace  SocketSever
{
    
public class Receive
    
{
        
/// <summary>
        
/// 获取投票信息
        
/// </summary>
        
/// <param name="contxt">内容</param>
        
/// <param name="endStr">结束符</param>
        
/// <returns></returns>

        public string[] contxtArry(string contxt, string endStr,char separator)
        
{
            
string[] tmparr = new string[3"","",""};
            contxt
=contxt.Replace(endStr, "").Trim();
            
if (contxt.IndexOf(separator.ToString()) > -1)
            
{
                
string[] tmp = contxt.Split(separator);
                
for (int i = 0; i < tmp.Length; i++)
                
{
                    tmparr[i] 
= tmp[i];
                }

            }

            
return tmparr;
        }


        
/// <summary>
        
/// 投票
        
/// </summary>
        
/// <param name="contxt">必须是contxtArry</param>
        
/// <returns></returns>

        public string voteResult(string[] contxt)
        
{
            Rules Rule 
= new Rules();
            
string statement = string.Empty;
            
string Number = string.Empty;
            
int tiCount = 0;
            
if (contxt[0!= string.Empty)
            
{
                statement 
= contxt[0];
            }

            
if (contxt[2!= string.Empty)
            
{
                
try
                
{
                    tiCount 
= Convert.ToInt32(contxt[2]);
                }

                
catch
                
{
                    tiCount 
= 1;
                }

            }

            
else
            
{
                tiCount 
= 1;
            }

            
if (contxt[1!= string.Empty)
            
{
                Number 
= contxt[1];
                
try
                
{
                    
if (Number != string.Empty)
                    
{
                        
return Rule.isVote(Number, statement, tiCount);
                    }

                    
else
                    
{
                        
return "404";
                    }

                }

                
catch (Exception ex)
                
{
                    
return "500.100";
                }

            }

            
else
            
{
                
return "000";
            }

            
        }

    }

}

 

就這樣俺就完成了這次開發,唉.....

悶~~~.

沒有激情...

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值