|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
public interface TcpSocket
Raw socket API for connecting and communicating over TCP.
This is a blocking socket, preliminary used for monitoring the uptime of socket services.
Here is an example that queries the HTTP server at example.com and prints out the HTTP headers.
var net = require('net');
test.beginTransaction();
test.beginStep();
var s = net.newSocket();
s.connect("google.com", 80);
s.send("GET http://www.google.com/ HTTP/1.1\r\n");
s.send("\r\n");
var r = s.readLine();
while (true) {
r = s.readLine();
if (r == null) {
break;
}
if (r == "") {
break;
}
test.log(r);
}
s.close();
test.endStep();
test.endTransaction();
| Method Summary | |
|---|---|
void |
close()
Close the connection. |
void |
connect(java.lang.String host,
int port)
Make a TCP connection to the given host#port. |
boolean |
isConnected()
Is the connection open? |
Bytes |
readBytes(int maxBytes)
Wait for data and return it. |
java.lang.String |
readLine()
Read a line of text and return it. |
void |
send(byte[] bytes)
Sends the given bytes over the socket to the destination. |
void |
send(Bytes bytes)
Sends the given bytes over the socket to the destination. |
void |
send(java.lang.String str)
Sends the given string over the socket to the destination as UTF8. |
void |
send(java.lang.String str,
java.lang.String charset)
Sends the given string over the socket to the destination in the given string encoding. |
void |
setTimeout(int timeout)
Make a TCP connection to the given host#port. |
| Method Detail |
|---|
void setTimeout(int timeout)
throws java.net.SocketException
timeout - the connect and receive timeout in milliseconds.
java.net.SocketException
void connect(java.lang.String host,
int port)
host - host to connect toport - port to connect tovoid send(java.lang.String str)
str - the string to send
void send(java.lang.String str,
java.lang.String charset)
str - the string to sendcharset - the charset to encode string.void send(Bytes bytes)
bytes - the bytes to sendvoid send(byte[] bytes)
bytes - the bytes to sendBytes readBytes(int maxBytes)
This is a blocking call.
Throws an exception if readLine() has been called previously and data is now buffered.
maxBytes -
java.lang.String readLine()
A line ending is one of \r, \n or \r\n.
This is a blocking call.
Content is buffered after calling this, and future calls to readBytes() will throw an exception.
void close()
boolean isConnected()
|
© 2023 Vercara, LLC. All Rights Reserved. | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||