| | 126 | /******************************************************************************* |
|---|
| | 127 | |
|---|
| | 128 | Creates a text-oriented server socket |
|---|
| | 129 | |
|---|
| | 130 | *******************************************************************************/ |
|---|
| | 131 | |
|---|
| | 132 | class TextServerSocket : ServerSocket |
|---|
| | 133 | { |
|---|
| | 134 | /*********************************************************************** |
|---|
| | 135 | |
|---|
| | 136 | Construct a ServerSocket on the given address, with the |
|---|
| | 137 | specified number of backlog connections supported. The |
|---|
| | 138 | socket is bound to the given address, and set to listen |
|---|
| | 139 | for incoming connections. Note that the socket address |
|---|
| | 140 | can be setup for reuse, so that a halted server may be |
|---|
| | 141 | restarted immediately. |
|---|
| | 142 | |
|---|
| | 143 | ***********************************************************************/ |
|---|
| | 144 | |
|---|
| | 145 | this (InternetAddress addr, int backlog=32, bool socketReuse=false) |
|---|
| | 146 | { |
|---|
| | 147 | super (addr, backlog, socketReuse); |
|---|
| | 148 | } |
|---|
| | 149 | |
|---|
| | 150 | |
|---|
| | 151 | /*********************************************************************** |
|---|
| | 152 | |
|---|
| | 153 | Overrides the default socket behaviour to create a socket |
|---|
| | 154 | for an incoming connection. Here we provide a text-based |
|---|
| | 155 | SocketConduit instead. |
|---|
| | 156 | |
|---|
| | 157 | ***********************************************************************/ |
|---|
| | 158 | |
|---|
| | 159 | protected override Socket createSocket (socket_t handle) |
|---|
| | 160 | { |
|---|
| | 161 | auto socket = TextSocketConduit.create (handle); |
|---|
| | 162 | |
|---|
| | 163 | // force abortive closure to avoid prolonged OS scavenging? |
|---|
| | 164 | if (linger >= 0) |
|---|
| | 165 | socket.setLingerPeriod (linger); |
|---|
| | 166 | |
|---|
| | 167 | return socket; |
|---|
| | 168 | } |
|---|
| | 169 | } |
|---|
| | 170 | |
|---|
| | 171 | |
|---|
| | 172 | |
|---|
| | 173 | |
|---|