Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions c_src/ex_libsrt/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ void Server::Run(const char* address, int port) {
throw std::runtime_error(std::string(srt_getlasterror_str()));
}

srt_listen_callback(srt_sock,
(srt_listen_callback_fn*)&Server::ListenAcceptCallback,
(void*)this);
srt_bind_sock = srt_listen(srt_sock, MAX_PENDING_CONNECTIONS);
if (srt_bind_sock == SRT_ERROR) {
throw std::runtime_error(std::string(srt_getlasterror_str()));
Expand All @@ -41,10 +44,6 @@ void Server::Run(const char* address, int port) {
const int read_modes = SRT_EPOLL_IN | SRT_EPOLL_ERR;
srt_epoll_add_usock(epoll, srt_sock, &read_modes);

srt_listen_callback(srt_sock,
(srt_listen_callback_fn*)&Server::ListenAcceptCallback,
(void*)this);

running.store(true);

epoll_loop = std::thread(&Server::RunEpoll, this);
Expand Down
12 changes: 4 additions & 8 deletions examples/server.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Mix.install([{:ex_libsrt, path: "../ex_libsrt"}])

Mix.install([{:ex_libsrt, path: "../"}])

defmodule Server do
use GenServer
Expand All @@ -19,7 +18,9 @@ defmodule Server do

@impl true
def handle_info({:srt_server_connect_request, address, stream_id}, state) do
Logger.info("Receiving new connection request with stream id: #{stream_id} from address: #{address}")
Logger.info(
"Receiving new connection request with stream id: #{stream_id} from address: #{address}"
)

:ok = ExLibSRT.Server.accept_awaiting_connect_request(state.server)

Expand Down Expand Up @@ -64,20 +65,15 @@ receive do
end

# Process.sleep(2_000)
#
for _i <- 1..10_000 do
payload = :crypto.strong_rand_bytes(1200)

:ok = ExLibSRT.Client.send_data(payload, client)
end



Process.sleep(5000)

ExLibSRT.Client.stop(client)

Process.sleep(1000)

GenServer.stop(server)