Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ var Request = exports.Request = function(opts) {
if (!this.server || !this.server.address || !net.isIP(this.server.address))
throw new Error('Server object must be supplied with at least address');

if (this.server.bind && !net.isIP(this.server.bind))
throw new Error('Server object bind attribute must be an IP address');

if (this.server.bind && this.server.type == 'tcp')
throw new Error('Bind attribute is not supported on tcp mode, sorry');

if (!this.server.type || ['udp', 'tcp'].indexOf(this.server.type) === -1)
this.server.type = 'udp';

Expand Down
8 changes: 6 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ var dgram = require('dgram'),
net = require('net'),
util = require('util');

var UDPSocket = exports.UDPSocket = function(socket, remote) {
var UDPSocket = exports.UDPSocket = function(socket, remote, bind) {
this._bind = bind;
this._socket = socket;
this._remote = remote;
this._buff = undefined;
Expand Down Expand Up @@ -72,7 +73,10 @@ UDPSocket.prototype.bind = function(type) {
self.emit('close');
});

this._socket.bind();
if (this._bind)
this._socket.bind(null, this._bind);
else
this._socket.bind();
}
};

Expand Down