1
package org.perl6.nqp.io;
3
import java.io.IOException;
4
import java.net.InetSocketAddress;
5
import java.nio.channels.SocketChannel;
6
import java.nio.charset.Charset;
8
import org.perl6.nqp.runtime.ExceptionHandling;
9
import org.perl6.nqp.runtime.ThreadContext;
11
public class SocketHandle extends SyncHandle {
13
public SocketHandle(ThreadContext tc) {
15
chan = SocketChannel.open();
16
setEncoding(tc, Charset.forName("UTF-8"));
17
} catch (IOException e) {
18
throw ExceptionHandling.dieInternal(tc, e);
22
public SocketHandle(ThreadContext tc, SocketChannel existing) {
24
setEncoding(tc, Charset.forName("UTF-8"));
27
public void connect(ThreadContext tc, String host, int port) {
29
InetSocketAddress addr = new InetSocketAddress(host, port);
30
((SocketChannel)chan).connect(addr);
31
} catch (IOException e) {
32
throw ExceptionHandling.dieInternal(tc, e);
36
public void flush(ThreadContext tc) {