Questions tagged [gen-tcp]

gen_tcp stands for 'Generic TCP' and is a module in Erlang that provides functions for TCP/IP communication.

80 questions
3
votes
2 answers

Erlang OTP supervisor gen_tcp - {error,eaddrinuse}

I'm failing to see how adding a supervisor to a crashing gen_tcp:listen-thread would actually restart that worker. Since crashing would render the port I wanna listen on useless for a brief moment. When a crash occur and I'm trying to manually…
3
votes
1 answer

TCP server not responding

I have the following TCP server written in Elixir utilizing the gen_tcp OTP module: defmodule Test do def server() do {:ok, listen_sock} = :gen_tcp.listen(43594, [{:active, true}, :binary]) {:ok, accept_sock} =…
leaf
  • 95
  • 5
3
votes
1 answer

Erlang tcp server/client sending messages

I'm currently writing a simple server which will work with clients connecting and then talking with eachother where the server acts as an intermediary. The setup is: Server starts 2 Clients connects to server Client1/2 sends a message with its…
Klesken
  • 35
  • 1
  • 6
2
votes
1 answer

Erlang gen_tcp:listen/2 for IPv6

I have .NET TCP Sender sending to an Erlang receiver. The .NET component likes to use the IPv6 address ::1 when resolving localhost. I'm not quite sure how to get Erlang to listen on the IPv6 address using gen_tcp. Here's my attempt. Am I telling…
batman
  • 1,447
  • 5
  • 16
  • 27
2
votes
1 answer

Erlang: Sending on a closed connection

If a client connects to a server over a normal tcp connection, and then later on the client's connection cuts out, the server will get (assuming active mode) {tcp_closed,Socket}. But there are cases where the server won't know that the client has…
Mediocre Gopher
  • 2,274
  • 1
  • 22
  • 39
2
votes
2 answers

What is difference between {active, false}, {active, true} and {active, once}?

as you probably know, there three modes of gen_tcp. {active, false}, {active, true} and {active, once}. I have read some documents about {active, false}, {active, true} and {active, once}. However, I didn't get it. What is difference between…
2
votes
1 answer

erlang/elixir gen_tcp connect - not connecting but telnet wil

I have a (zebra) printer that I can telnet to: jasongoodwin$ telnet 192.168.101.051 9100 Trying 192.168.101.51... Connected to 192.168.101.051. Escape character is '^]'. Then I can send it some data from the console and it will print a label for…
JasonG
  • 5,794
  • 4
  • 39
  • 67
2
votes
1 answer

Accepted socket from task failing in other process

I'm trying to test some elixir code and came across some behavior of gen_tcp I don't understand. When I gen_tcp.accept a socket I may "access" it in the task I created it in, but not a different one. I figured this was a "controlling_process" issue…
janders
  • 351
  • 1
  • 2
  • 9
2
votes
3 answers

Erlang SSL TCP Server And Garbage Collection

Edit: The issue seems to be with SSL acccpeting and a memory leak. I have noticed if you have long lived Processes(its a server), and clients send data to the server(recv), the Erlang garbage collection never gets called (or rarely) Servers need…
Mike5050
  • 625
  • 1
  • 7
  • 22
2
votes
1 answer

How To Use Erlang ssl:close/2

I have an SSL server, and I want to downgrade this after receiving the first ssl:recv to a raw gen_tcp. Assuming this can be used to do that I can not find an example on how to use this. And I am not so good at using the Erlang/OTP documentation yet…
Mike5050
  • 625
  • 1
  • 7
  • 22
2
votes
0 answers

Testing a concurrent server with multiple clients on localhost: error,econnrefused

I can't get multiple clients to communicate with my concurrent echo server. Here are my results: Server Terminal window: 1> c(s). {ok,s} 2> s:init(15555). Server started on port: 15555 Client Terminal window: 1> c(cl). {ok,cl} 2>…
7stud
  • 46,922
  • 14
  • 101
  • 127
2
votes
1 answer

Erlang client-server example using gen_tcp is not receiving anything

I am trying to receive data at client side, but nothing is received. Server code that sends message client(Socket, Server) -> gen_tcp:send(Socket,"Please enter your name"), io:format("Sent confirmation"), {ok, N} = gen_tcp:recv(Socket,0), …
Marko Taht
  • 1,448
  • 1
  • 20
  • 40
2
votes
1 answer

is there any way to get ether/ip headers via gen_tcp?

is there any way to get not only body of incoming message. but also ether/IP headers of it? Now i'm using gen_tcp and receive messages by active controlling process. for now socket is opened via 'of_driver' in such way: gen_tcp:connect(IpAddr, Port,…
2
votes
0 answers

tcp server accepting only some connections

I have a tcp server and a client. The client spawns 1000 processes each trying to connect to the tcp server. I can see that the tcp server is accepting 245 connections and rejecting all the rest. Every time, the server is accepting the first 245.…
listen
  • 217
  • 2
  • 7
2
votes
1 answer

How to stop a tcp_listener implemented as a gen_server in erlang

I implemented a tcp_listener as a gen_server(). I have a function called start_link(Port) creates a tcp_listener at that port. Now, I have trouble understanding how to tell the tcp_listener to stop listening through stop(). I tried calling a…
listen
  • 217
  • 2
  • 7