@@ -61,13 +61,13 @@ function Server (opts) {
6161
6262 // default to starting a udp server unless the user explicitly says no
6363 if ( opts . udp !== false ) {
64- self . _udpServer = dgram . createSocket ( 'udp4' )
65- self . _udpServer . on ( 'message' , self . _onUdpRequest . bind ( self ) )
66- self . _udpServer . on ( 'error' , self . _onError . bind ( self ) )
67- self . _udpServer . on ( 'listening' , onListening )
64+ self . _udpSocket = dgram . createSocket ( 'udp4' )
65+ self . _udpSocket . on ( 'message' , self . _onUdpRequest . bind ( self ) )
66+ self . _udpSocket . on ( 'error' , self . _onError . bind ( self ) )
67+ self . _udpSocket . on ( 'listening' , onListening )
6868 }
6969
70- var num = ! ! self . _httpServer + ! ! self . _udpServer
70+ var num = ! ! self . _httpServer + ! ! self . _udpSocket
7171 function onListening ( ) {
7272 num -= 1
7373 if ( num === 0 ) {
@@ -95,7 +95,7 @@ Server.prototype.listen = function (port, onlistening) {
9595 if ( err ) return self . emit ( 'error' , err )
9696 self . port = port
9797 self . _httpServer && self . _httpServer . listen ( port . http || port )
98- self . _udpServer && self . _udpServer . bind ( port . udp || port )
98+ self . _udpSocket && self . _udpSocket . bind ( port . udp || port )
9999 }
100100
101101 if ( port ) onPort ( null , port )
@@ -105,8 +105,8 @@ Server.prototype.listen = function (port, onlistening) {
105105Server . prototype . close = function ( cb ) {
106106 var self = this
107107 cb = cb || function ( ) { }
108- if ( self . _udpServer ) {
109- self . _udpServer . close ( )
108+ if ( self . _udpSocket ) {
109+ self . _udpSocket . close ( )
110110 }
111111 if ( self . _httpServer ) {
112112 self . _httpServer . close ( cb )
@@ -177,11 +177,10 @@ Server.prototype._onUdpRequest = function (msg, rinfo) {
177177 }
178178 }
179179
180- var socket = dgram . createSocket ( 'udp4' )
181180 response . transactionId = params . transactionId
182181 response . connectionId = params . connectionId
183182 var buf = makeUdpPacket ( response )
184- socket . send ( buf , 0 , buf . length , rinfo . port , rinfo . address , function ( ) {
183+ self . _udpSocket . send ( buf , 0 , buf . length , rinfo . port , rinfo . address , function ( ) {
185184 try {
186185 socket . close ( )
187186 } catch ( err ) { }
0 commit comments