Class: NetSocket

vertx-js/net_socket~ NetSocket

new NetSocket()

Represents a socket-like interface to a TCP connection on either the client or the server side.

Source:

Methods

close()

Close the NetSocket
Source:

closeHandler(handler) → {NetSocket}

Set a handler that will be called when the NetSocket is closed
Parameters:
Name Type Description
handler function the handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
NetSocket

drainHandler(handler) → {NetSocket}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
NetSocket

end(t)

Same as NetSocket#end but writes some data to the stream before ending.
Parameters:
Name Type Description
t Buffer
Source:

endHandler(endHandler) → {NetSocket}

Parameters:
Name Type Description
endHandler function
Source:
Returns:
Type
NetSocket

exceptionHandler(handler) → {NetSocket}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
NetSocket

handler(handler) → {NetSocket}

Parameters:
Name Type Description
handler function
Source:
Returns:
Type
NetSocket

indicatedServerName() → {string}

Returns the SNI server name presented during the SSL handshake by the client.
Source:
Returns:
the indicated server name
Type
string

isSsl() → {boolean}

Source:
Returns:
true if this NetSocket is encrypted via SSL/TLS.
Type
boolean

localAddress() → {SocketAddress}

Source:
Returns:
the local address for this socket
Type
SocketAddress

pause() → {NetSocket}

Source:
Returns:
Type
NetSocket

remoteAddress() → {SocketAddress}

Source:
Returns:
the remote address for this socket
Type
SocketAddress

resume() → {NetSocket}

Source:
Returns:
Type
NetSocket

sendFile(filename, offset, length, resultHandler) → {NetSocket}

Same as NetSocket#sendFile but also takes a handler that will be called when the send has completed or a failure has occurred
Parameters:
Name Type Description
filename string file name of the file to send
offset number offset
length number length
resultHandler function handler
Source:
Returns:
a reference to this, so the API can be used fluently
Type
NetSocket

setWriteQueueMaxSize(maxSize) → {NetSocket}

Parameters:
Name Type Description
maxSize number
Source:
Returns:
Type
NetSocket

upgradeToSsl(serverName, handler) → {NetSocket}

Upgrade channel to use SSL/TLS. Be aware that for this to work SSL must be configured.
Parameters:
Name Type Description
serverName string the server name
handler function the handler will be notified when it's upgraded
Source:
Returns:
a reference to this, so the API can be used fluently
Type
NetSocket

write(str, enc) → {NetSocket}

Write a String to the connection, encoded using the encoding enc.
Parameters:
Name Type Description
str string the string to write
enc string the encoding to use
Source:
Returns:
a reference to this, so the API can be used fluently
Type
NetSocket

writeHandlerID() → {string}

When a NetSocket is created it automatically registers an event handler with the event bus, the ID of that handler is given by writeHandlerID.

Given this ID, a different event loop can send a buffer to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other connections which are owned by different event loops.

Source:
Returns:
the write handler ID
Type
string

writeQueueFull() → {boolean}

This will return true if there are more bytes in the write queue than the value set using NetSocket#setWriteQueueMaxSize
Source:
Returns:
true if write queue is full
Type
boolean