Top Description Fields Methods
org.eclipse.jgit.internal.transport.sshd.agent.connector

pack-priv Interface UnixSockets

extends LibCAPI, Library
Imports
com.sun.jna.LastErrorException, .Library, .Structure, com.sun.jna.platform.unix.LibCAPI

Low-level Unix/Linux JNA socket API.

Field Summary

Modifier and TypeField and Description
public static final int
F_SETFD

Command to set the close-on-exec flag on a file descriptor via fcntl(int, int, int).

public static final int
FD_CLOEXEC

Specifies that a file descriptor shall not be inherited by child processes.

public static final String
LIBRARY_NAME

Library to load.

Inherited from com.sun.jna.Library:
OPTION_ALLOW_OBJECTSOPTION_CALLING_CONVENTIONOPTION_CLASSLOADEROPTION_FUNCTION_MAPPEROPTION_INVOCATION_MAPPEROPTION_OPEN_FLAGSOPTION_STRING_ENCODINGOPTION_STRUCTURE_ALIGNMENTOPTION_SYMBOL_PROVIDEROPTION_TYPE_MAPPER
Inherited from com.sun.jna.platform.unix.LibCAPI:
HOST_NAME_MAX

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

0 on success; -1 otherwise
connect
(int
file descriptor of the socket, as returned by socket(int, int, int)
fd
,
Sockets.SockAddr
address to connect to
addr
,
int
Length of addr, use Structure#size()
addrLen
)

Connects a file descriptor, which must refer to a socket, to a Sockets.SockAddr.

public int

Returns:

-1 on error, otherwise a value >= 0
fcntl
(int
file descriptor to operate on
fd
,
int
set to F_SETFD
command
,
int
zero to clear the close-on-exec flag, FD_CLOEXEC to set it
flag
)

Simple binding to fcntl; used to set the FD_CLOEXEC flag.

public LibCAPI.ssize_t

Returns:

number of bytes actually read; zero for EOF, -1 on error
read
(int
file descriptor to read from
fd
,
byte[]
buffer to read into
buf
,
LibCAPI.size_t
maximum number of bytes to read; at most length of buf
bufLen
)

Read data from a file descriptor.

public int

Returns:

file descriptor for the socket; should be closed eventually, or -1 on error.
socket
(int
socket domain; use Sockets#AF_UNIX
domain
,
int
socket type; use Sockets#SOCK_STREAM
type
,
int
socket communication protocol; use Sockets#DEFAULT_PROTOCOL.
protocol
)

Creates a socket and returns a file descriptor for it.

public LibCAPI.ssize_t

Returns:

number of bytes actually written; -1 on error
write
(int
file descriptor to write to
fd
,
byte[]
data to write
data
,
LibCAPI.size_t
number of bytes to write
dataLen
)

Write data to a file descriptor.

Inherited from com.sun.jna.platform.unix.LibCAPI:
closegetdomainnamegetegidgetenvgeteuidgetgidgethostnamegetloadavggetuidmsyncmunmapsetdomainnamesetegidsetenvseteuidsetgidsethostnamesetuidunsetenv

Field Detail

F_SETFDback to summary
public static final int F_SETFD

Command to set the close-on-exec flag on a file descriptor via fcntl(int, int, int).

FD_CLOEXECback to summary
public static final int FD_CLOEXEC

Specifies that a file descriptor shall not be inherited by child processes.

LIBRARY_NAMEback to summary
public static final String LIBRARY_NAME

Library to load. These functions live in libc.

Method Detail

connectback to summary
public int connect(int fd, Sockets.SockAddr addr, int addrLen) throws LastErrorException

Connects a file descriptor, which must refer to a socket, to a Sockets.SockAddr.

Parameters
fd:int

file descriptor of the socket, as returned by socket(int, int, int)

addr:Sockets.SockAddr

address to connect to

addrLen:int

Length of addr, use Structure#size()

Returns:int

0 on success; -1 otherwise

Exceptions
LastErrorException:
on errors
fcntlback to summary
public int fcntl(int fd, int command, int flag) throws LastErrorException

Simple binding to fcntl; used to set the FD_CLOEXEC flag. On OS X, we cannot include SOCK_CLOEXEC in the socket() call.

Parameters
fd:int

file descriptor to operate on

command:int

set to F_SETFD

flag:int

zero to clear the close-on-exec flag, FD_CLOEXEC to set it

Returns:int

-1 on error, otherwise a value >= 0

Exceptions
LastErrorException:
represents non-zero error code for the last error
readback to summary
public LibCAPI.ssize_t read(int fd, byte[] buf, LibCAPI.size_t bufLen) throws LastErrorException

Read data from a file descriptor.

Parameters
fd:int

file descriptor to read from

buf:byte[]

buffer to read into

bufLen:LibCAPI.size_t

maximum number of bytes to read; at most length of buf

Returns:LibCAPI.ssize_t

number of bytes actually read; zero for EOF, -1 on error

Exceptions
LastErrorException:
on errors
socketback to summary
public int socket(int domain, int type, int protocol) throws LastErrorException

Creates a socket and returns a file descriptor for it.

Parameters
domain:int

socket domain; use Sockets#AF_UNIX

type:int

socket type; use Sockets#SOCK_STREAM

protocol:int

socket communication protocol; use Sockets#DEFAULT_PROTOCOL.

Returns:int

file descriptor for the socket; should be closed eventually, or -1 on error.

Exceptions
LastErrorException:
on errors
See Also
LibCAPI#close(int)
writeback to summary
public LibCAPI.ssize_t write(int fd, byte[] data, LibCAPI.size_t dataLen) throws LastErrorException

Write data to a file descriptor.

Parameters
fd:int

file descriptor to write to

data:byte[]

data to write

dataLen:LibCAPI.size_t

number of bytes to write

Returns:LibCAPI.ssize_t

number of bytes actually written; -1 on error

Exceptions
LastErrorException:
on errors