Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
donaldh first hack on sockets for JVM.
- Loading branch information
Showing
3 changed files
with
205 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.perl6.nqp.io; | ||
|
||
import java.io.IOException; | ||
import java.net.InetSocketAddress; | ||
import java.nio.channels.SocketChannel; | ||
import java.nio.charset.Charset; | ||
|
||
import org.perl6.nqp.runtime.ExceptionHandling; | ||
import org.perl6.nqp.runtime.ThreadContext; | ||
|
||
public class SocketHandle extends SyncHandle { | ||
|
||
public SocketHandle(ThreadContext tc, String host, int port) { | ||
try { | ||
InetSocketAddress addr = InetSocketAddress.createUnresolved(host, port); | ||
chan = SocketChannel.open(addr); | ||
setEncoding(tc, Charset.forName("UTF-8")); | ||
} catch (IOException e) { | ||
throw ExceptionHandling.dieInternal(tc, e); | ||
} | ||
} | ||
} |
Oops, something went wrong.