Search in sources :

Example 1 with Feedback_OK

use of FLI.StreamUtils.Feedback_OK in project abstools by abstools.

the class Socket method fli_connect.

@Override
public Feedback<ABSUnit> fli_connect(ABSString server, ABSInteger port, ABSInteger timeout) {
    try {
        client_socket = new java.net.Socket();
        SocketAddress serverAddress = new InetSocketAddress(InetAddress.getByName(server.getString()), port.toInt());
        client_socket.connect(serverAddress, timeout.toInt());
        setupStream();
        input.setStream(new DataInputStream(client_socket.getInputStream()));
        output.setStream(new DataOutputStream(client_socket.getOutputStream()));
        return new Feedback_OK<ABSUnit>();
    } catch (Exception e) {
        e.printStackTrace();
        return new Feedback_Error<ABSUnit>(putil.convert(e.getMessage()));
    }
}
Also used : Feedback_OK(FLI.StreamUtils.Feedback_OK) InetSocketAddress(java.net.InetSocketAddress) DataOutputStream(java.io.DataOutputStream) ABSUnit(abs.backend.java.lib.types.ABSUnit) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) DataInputStream(java.io.DataInputStream) ABSAssertException(abs.backend.java.lib.runtime.ABSAssertException) IOException(java.io.IOException)

Example 2 with Feedback_OK

use of FLI.StreamUtils.Feedback_OK in project abstools by abstools.

the class ServerSocket method fli_bind.

@Override
public Feedback<ABSUnit> fli_bind(ABSInteger port) {
    try {
        socket = new java.net.ServerSocket();
        socket.bind(new InetSocketAddress(port.toInt()));
        return new Feedback_OK<ABSUnit>();
    } catch (Exception e) {
        return new Feedback_Error<ABSUnit>(putil.convert(e.getMessage()));
    }
}
Also used : Feedback_OK(FLI.StreamUtils.Feedback_OK) InetSocketAddress(java.net.InetSocketAddress) ABSUnit(abs.backend.java.lib.types.ABSUnit) IOException(java.io.IOException)

Aggregations

Feedback_OK (FLI.StreamUtils.Feedback_OK)2 ABSUnit (abs.backend.java.lib.types.ABSUnit)2 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 ABSAssertException (abs.backend.java.lib.runtime.ABSAssertException)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 SocketAddress (java.net.SocketAddress)1