natByteBufferImpl.cc, [...]: New files that implement native functionalities.
2002-11-29 Michael Koch <konqueror@gmx.de> * gnu/java/nio/natByteBufferImpl.cc, gnu/java/nio/natCharBufferImpl.cc, gnu/java/nio/natDoubleBufferImpl.cc, gnu/java/nio/natFloatBufferImpl.cc, gnu/java/nio/natIntBufferImpl.cc, gnu/java/nio/natLongBufferImpl.cc, gnu/java/nio/natSelectorImpl.cc, gnu/java/nio/natServerSocketChannelImpl.cc, gnu/java/nio/natShortBufferImpl.cc, gnu/java/nio/natSocketChannelImpl.cc: New files that implement native functionalities. From-SVN: r59625
This commit is contained in:
parent
ac7edc01e8
commit
38a21d46b0
11 changed files with 1222 additions and 0 deletions
130
libjava/gnu/java/nio/natSocketChannelImpl.cc
Normal file
130
libjava/gnu/java/nio/natSocketChannelImpl.cc
Normal file
|
@ -0,0 +1,130 @@
|
|||
// natSelectorImpl.cc
|
||||
|
||||
/* Copyright (C) 2002 Free Software Foundation
|
||||
|
||||
This file is part of libgcj.
|
||||
|
||||
This software is copyrighted work licensed under the terms of the
|
||||
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
||||
details. */
|
||||
|
||||
#include <config.h>
|
||||
#include <platform.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <gcj/cni.h>
|
||||
#include <gnu/java/nio/SocketChannelImpl.h>
|
||||
#include <java/io/IOException.h>
|
||||
#include <java/net/InetAddress.h>
|
||||
#include <java/net/SocketException.h>
|
||||
|
||||
jint
|
||||
gnu::java::nio::SocketChannelImpl::SocketCreate ()
|
||||
{
|
||||
int sock = _Jv_socket (AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
if (sock < 0)
|
||||
{
|
||||
char* strerr = strerror (errno);
|
||||
throw new ::java::io::IOException (JvNewStringUTF (strerr));
|
||||
}
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
jint
|
||||
gnu::java::nio::SocketChannelImpl::SocketConnect (jint fd,
|
||||
::java::net::InetAddress *addr,
|
||||
jint port)
|
||||
{
|
||||
int result = _Jv_connect_address (fd, addr, port, addr, port);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
char* strerr = strerror (errno);
|
||||
throw new ::java::io::IOException (JvNewStringUTF (strerr));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jint
|
||||
gnu::java::nio::SocketChannelImpl::SocketBind (jint fd,
|
||||
::java::net::InetAddress *addr,
|
||||
jint port)
|
||||
{
|
||||
int result = _Jv_bind_address (fd, addr, port);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
char* strerr = strerror (errno);
|
||||
throw new ::java::io::IOException (JvNewStringUTF (strerr));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jint
|
||||
gnu::java::nio::SocketChannelImpl::SocketListen (jint fd, jint backlog)
|
||||
{
|
||||
int result = _Jv_listen (fd, backlog);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
char* strerr = strerror (errno);
|
||||
throw new ::java::io::IOException (JvNewStringUTF (strerr));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jint
|
||||
gnu::java::nio::SocketChannelImpl::SocketAvailable (jint /*fd*/)
|
||||
{
|
||||
throw new ::java::net::SocketException (JvNewStringLatin1 ("SocketAvailable: not implemented"));
|
||||
}
|
||||
|
||||
jint
|
||||
gnu::java::nio::SocketChannelImpl::SocketClose (jint fd)
|
||||
{
|
||||
int result = _Jv_close (fd);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
char* strerr = strerror (errno);
|
||||
throw new ::java::io::IOException (JvNewStringUTF (strerr));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jint
|
||||
gnu::java::nio::SocketChannelImpl::SocketRead (jint fd, jbyteArray data,
|
||||
jint offset, jint length)
|
||||
{
|
||||
int result = ::recv (fd, data, offset, length);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
char* strerr = strerror (errno);
|
||||
throw new ::java::io::IOException (JvNewStringUTF (strerr));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jint
|
||||
gnu::java::nio::SocketChannelImpl::SocketWrite (jint fd, jbyteArray data,
|
||||
jint offset, jint length)
|
||||
{
|
||||
int result = ::send (fd, data, offset, length);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
char* strerr = strerror (errno);
|
||||
throw new ::java::io::IOException (JvNewStringUTF (strerr));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue