ab56a9bcf7
SVN-Revision: r240
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Configuration;
|
|
using System.Net;
|
|
using System.IO;
|
|
|
|
namespace Lskj.SocketService
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
private string _fileDirectory = @"E:\Scoket\Files";
|
|
private int _port = 9999;
|
|
private int _parallelNum = 8000;
|
|
private int _socketTimeOutMS = 5 * 60 * 1000;
|
|
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SocketApp.FileDirectory = _fileDirectory;
|
|
if (string.IsNullOrWhiteSpace(SocketApp.FileDirectory))
|
|
SocketApp.FileDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Files");
|
|
if (!Directory.Exists(SocketApp.FileDirectory))
|
|
Directory.CreateDirectory(SocketApp.FileDirectory);
|
|
|
|
SocketApp.AsyncSocketSvr = new AsyncSocketServer(_parallelNum);
|
|
SocketApp.AsyncSocketSvr.SocketTimeOutMS = _socketTimeOutMS;
|
|
SocketApp.AsyncSocketSvr.Init();
|
|
IPEndPoint listenPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), _port);
|
|
SocketApp.AsyncSocketSvr.Start(listenPoint);
|
|
|
|
this.textBox1.Text = "启动成功.等待连接.";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|