Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.squawk.platform.windows.natives
Interface Socket

All Superinterfaces:
  Library

All Known Implementing Classes:
  SocketImpl

    public interface Socket

extends Library

java wrapper around BSD sockets

Nested Class Summary
`static class` | `Socket.sockaddr_in` C STRUCTURE sockaddr_in / struct sockaddr_in { u_char sin_len; 1 u_char sin_family; 1 u_short sin_port; 2 struct in_addr sin_addr; 4 char sin_zero[8]; 8 }; struct sockaddr { __uint8_t sa_len; /* total length sa_family_t sa_family; /* [XSI] address family char sa_data[14]; /* [XSI] addr value (actually larger) };

Field Summary
`static int` | `AF_INET`
`static int` | `INADDR_ANY`
`static int` | `INET_ADDRSTRLEN`
`static Socket` | `INSTANCE`
`static int` | `SO_ACCEPTCONN`
`static int` | `SO_BROADCAST`
`static int` | `SO_DEBUG`
`static int` | `SO_DONTROUTE`
`static int` | `SO_KEEPALIVE`
`static int` | `SO_OOBINLINE`
`static int` | `SO_REUSEADDR`
`static int` | `SOCK_DGRAM`
`static int` | `SOCK_RAW`
`static int` | `SOCK_STREAM`
`static int` | `SOL_SOCKET`

Method Summary
`int` | `accept(int socket, Socket.sockaddr_in remoteAddress, IntByReference address_len)` accept a connection from a client
`int` | `bind(int socket, Socket.sockaddr_in myaddress)` bind a socket to a port
`int` | `connect(int socket, Socket.sockaddr_in address, int address_len)` initiate a connection on a socket.
`int` | `getsockopt(int socket, int level, int option_name, ByReference option_value, IntByReference option_len)` get a socket option
`String` | `inet_ntop(int af, IntByReference src, Pointer dst, int size)` Takes an IPv4 Internet address and returns string representing the address in `.' notation
`boolean` | `inet_pton(String str, IntByReference in_addr)` Interprets the specified character string as an Internet address, placing the address into the structure provided.
`int` | `listen(int socket, int backlog)` listen for connections on socket
`int` | `setsockopt(int socket, int level, int option_name, ByReference option_value, int option_len)` set a socket option
`int` | `shutdown(int socket, int how)` initiate a connection on a socket.
`int` | `socket(int domain, int type, int protocol)` socket() creates an endpoint for communication and returns a descriptor.

Methods inherited from interface com.sun.cldc.jna.Library
`initConstInt`

Field Detail

### INSTANCE

    static final Socket INSTANCE

### AF_INET

    static final int AF_INET

See Also:
  Constant Field Values

### SOCK_STREAM

    static final int SOCK_STREAM

See Also:
  Constant Field Values

### SOCK_DGRAM

    static final int SOCK_DGRAM

See Also:
  Constant Field Values

### SOCK_RAW

    static final int SOCK_RAW

See Also:
  Constant Field Values

### INADDR_ANY

    static final int INADDR_ANY

See Also:
  Constant Field Values

### INET_ADDRSTRLEN

    static final int INET_ADDRSTRLEN

See Also:
  Constant Field Values

### SOL_SOCKET

    static final int SOL_SOCKET

See Also:
  Constant Field Values

### SO_DEBUG

    static final int SO_DEBUG

See Also:
  Constant Field Values

### SO_ACCEPTCONN

    static final int SO_ACCEPTCONN

See Also:
  Constant Field Values

### SO_REUSEADDR

    static final int SO_REUSEADDR

See Also:
  Constant Field Values

### SO_KEEPALIVE

    static final int SO_KEEPALIVE

See Also:
  Constant Field Values

### SO_DONTROUTE

    static final int SO_DONTROUTE

See Also:
  Constant Field Values

### SO_BROADCAST

    static final int SO_BROADCAST

See Also:
  Constant Field Values

### SO_OOBINLINE

    static final int SO_OOBINLINE

See Also:
  Constant Field Values

Method Detail

### socket

    int socket(int domain,
               int type,
               int protocol)

  socket() creates an endpoint for communication and returns a descriptor.

  Parameters:
    `domain` - specifies a communications domain within which communication will take place; this selects the protocol family which should be used. The currently understood formats are: AF_UNIX, AF_INET, AF_ISO, AF_NS, AF_IMPLINK
    `type` - specifies the semantics of communication. Currently defined types are: SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM
    `protocol` - The protocol number to use is particular to the communication domain in which communication is to take place; see protocols(5).
  Returns:
    A -1 is returned if an error occurs, otherwise the return value is a descriptor referencing the socket.

### connect

    int connect(int socket,
                Socket.sockaddr_in address,
                int address_len)

  initiate a connection on a socket.

  Parameters:
    `socket` - socket descriptor
    `address` - ptr to a sockaddr_in buffer
    `address_len` - pass in sockaddr_in.size()
  Returns:
    A -1 is returned if an error occurs, otherwise the return value is a descriptor referencing the socket.

### bind

    int bind(int socket,
             Socket.sockaddr_in myaddress)

  bind a socket to a port

  Parameters:
    `socket` - socket descriptor
    `myaddress` - ptr to a SockAddr_In buffer
  Returns:
    A -1 is returned if an error occurs, otherwise the return value is a descriptor referencing the socket.

### accept

    int accept(int socket,
               Socket.sockaddr_in remoteAddress,
               IntByReference address_len)

  accept a connection from a client

  Parameters:
    `socket` - socket descriptor
    `remoteAddress` - ptr to a SockAddr_In buffer that will contain the address of the remote client
    `address_len` - pointer to int containing the size of an IP address
  Returns:
    A -1 is returned if an error occurs, otherwise the return value is a descriptor referencing the socket.

### listen

    int listen(int socket,
               int backlog)

  listen for connections on socket

  Parameters:
    `socket` - socket descriptor
    `backlog` -
  Returns:
    A -1 is returned if an error occurs, otherwise the return value is a descriptor referencing the socket.

### shutdown

    int shutdown(int socket,
                 int how)

  initiate a connection on a socket.

  Parameters:
    `socket` - socket descriptor
    `how` - If how is SHUT_RD, further receives will be disallowed. If how is SHUT_WR, further sends will be disallowed. If how is SHUT_RDWR, further sends and receives will be disallowed.
  Returns:
    A -1 is returned if an error occurs, otherwise zero is returned

### inet_pton

    boolean inet_pton(String str,
                      IntByReference in_addr)

  Interprets the specified character string as an Internet address, placing the address into the structure provided. It returns 1 if the string was successfully interpreted, or 0 if the string is invalid

  Parameters:
    `str` -
    `in_addr` - (OUT) on sucessful return will contain the 32 bits of an IPv4 "struct in_addr"
  Returns:
    true if success

### inet_ntop

    String inet_ntop(int af,
                     IntByReference src,
                     Pointer dst,
                     int size)

  Takes an IPv4 Internet address and returns string representing the address in `.' notation

  Parameters:
    `af` - family (should be AF_INET)
    `src` - a pointer to the src internet address
    `dst` - a pointer to tmp buffer used to store characters for the result.
    `size` - the size of the tmp dst buffer
  Returns:
    String (created from the characters in the dst buffer)

### setsockopt

    int setsockopt(int socket,
                   int level,
                   int option_name,
                   ByReference option_value,
                   int option_len)

  set a socket option

  Parameters:
    `socket` - socket descriptor
    `level` -
    `option_name` -
    `option_value` -
    `option_len` - (option_value.size()
  Returns:
    A -1 is returned if an error occurs, otherwise the return value is a descriptor referencing the socket.

### getsockopt

    int getsockopt(int socket,
                   int level,
                   int option_name,
                   ByReference option_value,
                   IntByReference option_len)

  get a socket option

  Parameters:
    `socket` - socket descriptor
    `level` -
    `option_name` -
    `option_value` -
    `option_len` - On return, the by-reference int will contain the size of the option_value data
  Returns:
    A -1 is returned if an error occurs, otherwise the return value is a descriptor referencing the socket.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"