1
2
3
4
5
6 using System;
7
8 namespace System.Net.Sockets
9 {
10 public class TcpListener
11 {
12 public TcpListener(int port_) : socket(), port(port_)
13 {
14 socket.Bind(port);
15 }
16 public void Start()
17 {
18 Start(256);
19 }
20 public void Start(int backLog)
21 {
22 socket.Listen(backLog);
23 }
24 public void Stop()
25 {
26 socket.Close();
27 socket = TcpSocket();
28 socket.Bind(port);
29 }
30 public TcpSocket AcceptSocket()
31 {
32 return socket.Accept();
33 }
34 public TcpSocket& ContainedSocket()
35 {
36 return socket;
37 }
38 private TcpSocket socket;
39 private int port;
40 }
41 }