ServerDS NewServerDS(IDSI dsiReq) { while (true) { lock (servs) { if (evExit.WaitOne(0, false)) { throw new ExitShotException(); } if (servs.Count >= MaxSim) { Thread.Sleep(25); continue; } else { ushort RId = this.RId++; ServerDS serv = new ServerDS(); serv.dsiReq = dsiReq; serv.RId = RId; servs.Add(serv); return(serv); } } } }
public TransmitRes Transmit(IDSI dsiReq) { ServerDS sv; try { sv = NewServerDS(dsiReq); } catch (ExitShotException err) { throw new TransmitFailureException(err); } try { try { lock (Sock) { Sock.Send(dsiReq.ToArray(sv.RId)); } } catch (SocketException err) { throw new TransmitFailureException(err); } sv.evRecv.WaitOne(); if (sv.err != null) { throw new TransmitFailureException(sv.err); } return(new TransmitRes(sv.dsiRes)); } finally { DisconnectServerDS(sv); } }
public void Send(IDSI dsiReq) { ServerDS sv; try { sv = NewServerDS(dsiReq); } catch (ExitShotException err) { throw new TransmitFailureException(err); } try { try { lock (Sock) { Sock.Send(dsiReq.ToArray(sv.RId)); } } catch (SocketException err) { throw new TransmitFailureException(err); } return; } finally { DisconnectServerDS(sv); } }
ServerDS NewServerDS(IDSI dsiReq) { while (true) { lock (servs) { if (evExit.WaitOne(0, false)) throw new ExitShotException(); if (servs.Count >= MaxSim) { Thread.Sleep(25); continue; } else { ushort RId = this.RId++; ServerDS serv = new ServerDS(); serv.dsiReq = dsiReq; serv.RId = RId; servs.Add(serv); return serv; } } } }
public TransmitRes Transmit(IDSI dsiReq) { ServerDS sv; try { sv = NewServerDS(dsiReq); } catch (ExitShotException err) { throw new TransmitFailureException(err); } try { try { lock (Sock) { Sock.Send(dsiReq.ToArray(sv.RId)); } } catch (SocketException err) { throw new TransmitFailureException(err); } sv.evRecv.WaitOne(); if (sv.err != null) throw new TransmitFailureException(sv.err); return new TransmitRes(sv.dsiRes); } finally { DisconnectServerDS(sv); } }
public void Send(IDSI dsiReq) { ServerDS sv; try { sv = NewServerDS(dsiReq); } catch (ExitShotException err) { throw new TransmitFailureException(err); } try { try { lock (Sock) { Sock.Send(dsiReq.ToArray(sv.RId)); } } catch (SocketException err) { throw new TransmitFailureException(err); } return; } finally { DisconnectServerDS(sv); } }