gen_tcp stands for 'Generic TCP' and is a module in Erlang that provides functions for TCP/IP communication.
Questions tagged [gen-tcp]
80 questions
9
votes
1 answer
gen_tcp receive extremely high CPU
Sorry that I'm an Erlang newbie and may make stupid question. But please help me to solve the issue.
I have written an Erlang server to replace the one I'm using with Node.js, which ate all my memory and I'm praying that Erlang could be a way…

Anita
- 119
- 5
7
votes
1 answer
Erlang simultaneously connect 1M clients
I have a problem: I want to create an Erlang server that can hold 1M simultaneous open tcp connection. I tuned my OS (Oracle Linux 7) to raise the file descriptors.
On the server I do
gen_tcp:listen
// point_1
Socket =…

Ștefan Stan
- 223
- 1
- 7
7
votes
1 answer
Is using Erlang's gen_tcp a scalable way to construct a high traffic socket server
I am trying to learn Erlang to do some simple but scalable network programming. I basically want to write a program that does what servers on the backbone of the internet do--but on a smaller scale. I want to try to set up an intranet with web…

Alex Eftimiades
- 2,527
- 3
- 24
- 33
5
votes
1 answer
gen_tcp smushed messages
I'm using socket_server from this tutorial and the following code for a client and server:
Server:
-module(echo_server).
-export([start/0, loop/1]).
% echo_server specific code
start() ->
spawn(socket_server, start, [?MODULE, 7000, {?MODULE,…

nmichaels
- 49,466
- 12
- 107
- 135
4
votes
2 answers
gen_server closing listening socket
What I'm trying to do is have a gen_server process accept a new client and immediately spawn a new child to handle the next one. The issue that I'm seeing is that when the socket is finished and consequentially terminates, it also closes the…

Refefer
- 541
- 4
- 11
4
votes
1 answer
Half-Established TCP Connections
Half-Established Connections
With a half-established connection I mean a connection for which the client's call to connect() returned successfully, but the servers call to accept() didn't. This can happen the following way: The client calls…

jvf
- 866
- 7
- 13
4
votes
1 answer
erlang: to controlling_process(), or not to controlling_process()
Consider the following erlang code of a simple echo server:
Echo listener:
-module(echo_listener).
-export([start_link/1]).
-define(TCP_OPTIONS, [binary, {packet, 0}, {reuseaddr, true},
{keepalive, true}, {backlog, 30},…

Romstar
- 1,139
- 3
- 14
- 21
4
votes
1 answer
Erlang: gen_tcp:recv() does not receive packet sent from client?
I modified this server to use gen_tcp:recv inorder to limit the number of bytes for a packet to 50. I commented out the line inet:setopts(Socket, [{active, once}]), because gen_tcp:recv is supposed to be {active,false}. This is the client side erl…

pandoragami
- 5,387
- 15
- 68
- 116
3
votes
1 answer
How to edit echo server to allow many clients to exchange messages
I've created a server with no client code. I just have to type on the terminal telnet 127.0.0.1 4001 and on an other terminal telnet 127.0.0.2 4001 so when I type a message on the first terminal it appears on the same terminal, I know this an echo…

Mariem
- 133
- 5
3
votes
1 answer
erlang: how to receive HTTP/RTSP messages from socket?
I want to manage HTTP or RTSP sessions with Erlang.
For example, a standart session for RTSP protocol looks like:
OPTIONS rtsp://192.168.1.55/test/ RTSP/1.0\r\n
CSeq: 1\r\n
User-Agent: VLC media player (LIVE555 Streaming Media…

Nick Saw
- 457
- 4
- 15
3
votes
1 answer
How can I detect a TCP timeout on an active socket in Elixir with gen_tcp?
I have a GenServerthat is connecting to a remote TCP connection via gen_tcp.
opts = [:binary, active: true, packet: :line]
{:ok, socket} = :gen_tcp.connect('remote-url', 8000, opts}
I'm handling messages with:
def handle_info({:tcp, socket, msg},…

user2666425
- 1,671
- 1
- 15
- 21
3
votes
1 answer
gen_tcp:recv/2 returns error, einval
I have a client that creates N processes and all connecting to a server like this:
send(State = #state{low = Low, high = Low}) ->
NewState = receive_sockets(0, Low, State),
NewState;
send(State = #state{low = Low}) ->
N = Low rem 10,
Dest…

listen
- 217
- 2
- 7
3
votes
1 answer
Interrupting gen_tcp:recv in erlang
We have a gen_server process that manages the pool of passive sockets on the client side by creating them and borrowing them for other processes. Any other process can borrow a socket, sends a request to the server using the socket, gets a reply…

Mayya Sharipova
- 405
- 4
- 11
3
votes
1 answer
Erlang TCP sockets get closed
To learn Erlang I am trying to implement a tiny web server based on gen_tcp. Unfortunately, my code seems to trigger some wired behaviour. To demonstrate the problem I have attached a minimised version of my implementation which is sufficient to…

aka
- 2,723
- 1
- 14
- 10
3
votes
2 answers
The difference between passive and once mode of gen_tcp
I'm reading Programming Erlang 2E. In Active and Passive Sockets of Chapter 17, it says:
You might think that using passive mode for all servers is the correct
approach. Unfortunately, when we’re in passive mode, we can wait for
the data from…

an0
- 17,191
- 12
- 86
- 136