Basic creating of a Non-secure TCP listener.

In this case one which listens on port 21.
new NonsecureTcpListener(21);

Creating a server that uses NonsecureTcpLisener:

public class MyState : AbstractState {
  public MyState(IListener listener, ISocket clientSocket) : base(listener, clientSocket) {
  }
}

public class MyServer : AbstractServer {
  public MyServer() {
    InitializeState += MyInitializeState;
  }

  public override IState CreateState(IListener listener, ISocket clientSocket) {
    return new MyState(listener, clientSocket);
  }

  public void MyInitializeState(IServer server, IState stateArg) {
    MyState state = (MyState)stateArg;
    state.DataReceived += DataReceived;
  }

  private void DataReceived(IState state, byte[] buffer, int received) {
    // process data and send responses.
  }
}

Last edited Nov 25, 2007 at 3:08 PM by joegtp, version 6

Comments

No comments yet.