@@ -45,12 +45,12 @@ internal class TcpListener : Own, IProactorEvents
4545 /// </summary>
4646 private AsyncSocket ? m_handle ;
4747
48- /*
49- /// <summary>
50- /// socket being accepted
51- /// </summary>
52- private AsyncSocket m_acceptedSocket;
53- */
48+ /*
49+ /// <summary>
50+ /// socket being accepted
51+ /// </summary>
52+ private AsyncSocket m_acceptedSocket;
53+ */
5454
5555 /// <summary>
5656 /// Socket the listener belongs to.
@@ -107,7 +107,7 @@ protected override void ProcessPlug()
107107 protected override void ProcessTerm ( int linger )
108108 {
109109 Assumes . NotNull ( m_handle ) ;
110-
110+
111111 m_ioObject . SetHandler ( this ) ;
112112 m_ioObject . RemoveSocket ( m_handle ) ;
113113 Close ( ) ;
@@ -123,7 +123,7 @@ public virtual void SetAddress(string addr)
123123 m_address . Resolve ( addr , m_options . IPv4Only ) ;
124124
125125 Assumes . NotNull ( m_address . Address ) ;
126-
126+
127127
128128 try
129129 {
@@ -195,75 +195,74 @@ public void InCompleted(SocketError socketError, int bytesTransferred)
195195 switch ( socketError )
196196 {
197197 case SocketError . Success :
198- {
199- // TODO: check TcpFilters
200- var acceptedSocket = m_handle . GetAcceptedSocket ( ) ;
198+ {
199+ // TODO: check TcpFilters
200+ var acceptedSocket = m_handle . GetAcceptedSocket ( ) ;
201201
202202 acceptedSocket . NoDelay = true ;
203203
204- if ( m_options . TcpKeepalive != - 1 )
205- {
206- acceptedSocket . SetSocketOption ( SocketOptionLevel . Socket , SocketOptionName . KeepAlive , m_options . TcpKeepalive ) ;
204+ if ( m_options . TcpKeepalive != - 1 )
205+ {
206+ acceptedSocket . SetSocketOption ( SocketOptionLevel . Socket , SocketOptionName . KeepAlive , m_options . TcpKeepalive ) ;
207207
208- if ( m_options . TcpKeepaliveIdle != - 1 && m_options . TcpKeepaliveIntvl != - 1 )
209- {
210- var bytes = new ByteArraySegment ( new byte [ 12 ] ) ;
208+ if ( m_options . TcpKeepaliveIdle != - 1 && m_options . TcpKeepaliveIntvl != - 1 )
209+ {
210+ var bytes = new ByteArraySegment ( new byte [ 12 ] ) ;
211211
212- Endianness endian = BitConverter . IsLittleEndian ? Endianness . Little : Endianness . Big ;
212+ Endianness endian = BitConverter . IsLittleEndian ? Endianness . Little : Endianness . Big ;
213213
214- bytes . PutInteger ( endian , m_options . TcpKeepalive , 0 ) ;
215- bytes . PutInteger ( endian , m_options . TcpKeepaliveIdle , 4 ) ;
216- bytes . PutInteger ( endian , m_options . TcpKeepaliveIntvl , 8 ) ;
214+ bytes . PutInteger ( endian , m_options . TcpKeepalive , 0 ) ;
215+ bytes . PutInteger ( endian , m_options . TcpKeepaliveIdle , 4 ) ;
216+ bytes . PutInteger ( endian , m_options . TcpKeepaliveIntvl , 8 ) ;
217217#if NET
218218 if ( ! OperatingSystem . IsWindows ( ) )
219219 {
220220 throw new InvalidOperationException ( "Not supported on you platform" ) ; // There is a pull request for .net8.0
221221
222222 }
223223#endif
224- acceptedSocket . IOControl ( IOControlCode . KeepAliveValues , ( byte [ ] ) bytes , null ) ;
225-
226- }
224+ acceptedSocket . IOControl ( IOControlCode . KeepAliveValues , ( byte [ ] ) bytes , null ) ;
227225 }
226+ }
228227
229- // Create the engine object for this connection.
230- var engine = new StreamEngine ( acceptedSocket , m_options , m_endpoint ) ;
228+ // Create the engine object for this connection.
229+ var engine = new StreamEngine ( acceptedSocket , m_options , m_endpoint ) ;
231230
232- // Choose I/O thread to run connector in. Given that we are already
233- // running in an I/O thread, there must be at least one available.
234- IOThread ? ioThread = ChooseIOThread ( m_options . Affinity ) ;
231+ // Choose I/O thread to run connector in. Given that we are already
232+ // running in an I/O thread, there must be at least one available.
233+ IOThread ? ioThread = ChooseIOThread ( m_options . Affinity ) ;
235234
236- Assumes . NotNull ( ioThread ) ;
235+ Assumes . NotNull ( ioThread ) ;
237236
238- // Create and launch a session object.
239- // TODO: send null in address parameter, is unneeded in this case
240- SessionBase session = SessionBase . Create ( ioThread , false , m_socket , m_options , new Address ( m_handle . LocalEndPoint ) ) ;
241- session . IncSeqnum ( ) ;
242- LaunchChild ( session ) ;
237+ // Create and launch a session object.
238+ // TODO: send null in address parameter, is unneeded in this case
239+ SessionBase session = SessionBase . Create ( ioThread , false , m_socket , m_options , new Address ( m_handle . LocalEndPoint ) ) ;
240+ session . IncSeqnum ( ) ;
241+ LaunchChild ( session ) ;
243242
244- SendAttach ( session , engine , false ) ;
243+ SendAttach ( session , engine , false ) ;
245244
246- m_socket . EventAccepted ( m_endpoint , acceptedSocket ) ;
245+ m_socket . EventAccepted ( m_endpoint , acceptedSocket ) ;
247246
248- Accept ( ) ;
249- break ;
250- }
247+ Accept ( ) ;
248+ break ;
249+ }
251250 case SocketError . ConnectionReset :
252251 case SocketError . NoBufferSpaceAvailable :
253252 case SocketError . TooManyOpenSockets :
254- {
255- m_socket . EventAcceptFailed ( m_endpoint , socketError . ToErrorCode ( ) ) ;
253+ {
254+ m_socket . EventAcceptFailed ( m_endpoint , socketError . ToErrorCode ( ) ) ;
256255
257- Accept ( ) ;
258- break ;
259- }
256+ Accept ( ) ;
257+ break ;
258+ }
260259 default :
261- {
262- NetMQException exception = NetMQException . Create ( socketError ) ;
260+ {
261+ NetMQException exception = NetMQException . Create ( socketError ) ;
263262
264- m_socket . EventAcceptFailed ( m_endpoint , exception . ErrorCode ) ;
265- throw exception ;
266- }
263+ m_socket . EventAcceptFailed ( m_endpoint , exception . ErrorCode ) ;
264+ throw exception ;
265+ }
267266 }
268267 }
269268
0 commit comments