kafka_ex v0.6.2 KafkaEx.Socket

This module handle all socket related operations.

Summary

Functions

Closes the socket

Returns the information about the socket

Receives data from the socket

Sends data over the socket

Set options to the socket

Types

t()
t() :: %KafkaEx.Socket{socket: :gen_tcp.socket | :ssl.sslsocket, ssl: boolean}

Functions

close(socket)
close(KafkaEx.Socket.t) :: :ok

Closes the socket.

For more information, see :ssl.close/1 for ssl or :gen_tcp.send/1 for non ssl.

create(host, port, socket_options \\ [], is_ssl \\ false)

Creates a socket.

For more information about the available options, see :ssl.connect/3 for ssl or :gen_tcp.connect/3 for non ssl.

info(socket)
info(KafkaEx.Socket.t | nil) :: list | nil

Returns the information about the socket.

For more information, see Port.info

recv(socket, length)
recv(KafkaEx.Socket.t, non_neg_integer) ::
  {:ok, String.t | binary | term} |
  {:error, any}

Receives data from the socket.

For more information, see :ssl.recv/2 for ssl or :gen_tcp.recv/2 for non ssl.

recv(socket, length, timeout)
recv(KafkaEx.Socket.t, non_neg_integer, timeout) ::
  {:ok, String.t | binary | term} |
  {:error, any}
send(socket, data)
send(KafkaEx.Socket.t, iodata) :: :ok | {:error, any}

Sends data over the socket.

It handles both, SSL and non SSL sockets.

For more information, see :ssl.send/2 for ssl or :gen_tcp.send/2 for non ssl.

setopts(socket, options)
setopts(KafkaEx.Socket.t, list) :: :ok | {:error, any}

Set options to the socket.

For more information, see :ssl.setopts/2 for ssl or :inet.setopts/2 for non ssl.