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
1
vote
1 answer
erlang gen_tcp:recv block
Hi I have this situation:
gen_tcp:connect(Address, Port, [{buffer, 1024},{active, false},{packet,0},{send_timeout, infinity}]).
and I use gen_tcp:recv(Sock,0), but the message from the server don't have a particular end pattern, so there's any way…

user1524704
- 21
- 1
0
votes
2 answers
How can I identify a complete response when receive lot of packets in concurrent TCP requests
I have a single TCP connection to a server, but possibly have multiple requests at the same time. Most of the time the response will be so big that I would constantly receive lot of data chunks. It's possible for me to check the data length in order…

CW LOK
- 3
- 1
0
votes
1 answer
Strange behavior of OTP gen_tcp with settings {packet,4} and using NodeJS "frame-stream'' for TCP communication
I've been struggling for a while to get my messages framed correctly between my NodeJS server and my erlang gen_tcp server. I was using {packet,line} successfully until I had to send large data messages and needed to switch to message size…

Dale Sparrow
- 121
- 7
0
votes
1 answer
Store erlang socket to database
I need to store sockets into database,
gen_tcp:accept returns something like
#Port<0.5>
I can convert it to a bitstring using io_lib:format
["Port<0.5>"]
to store it into database but how do i convert it back to its original state to use it to…

asim
- 533
- 6
- 17
0
votes
2 answers
How can I get the MAC address from a socket returned from gen_tcp:accept/1?
So far I have the following Elixir code
{:ok, server_socket} = :gen_tcp.listen(port)
{:ok, client_socket} = :gen_tcp.accept(server_socket)
How can I get the MAC address from the client_socket?
P.S. I know that the MAC address is changed every hop,…

Aetherus
- 8,720
- 1
- 22
- 36
0
votes
3 answers
Correct way of using gen_tcp:connect with IPv6 Address
Does anyone know how to connect to ipv6 tcp server address. Following tried but does not work.
{ok, Socket} = gen_tcp:connect("2a01:488:67:1000:253d:cd31:0:1", 5000, [{active, false},inet6]).
{error,enetunreach}
And this
{ok, Socket} =…

user3404572
- 167
- 8
0
votes
1 answer
Can't connect to specific network interface
i've read docs for 'inet', 'gen_tcp', but can't understand where is error.
connect_option() =
{ip, inet:socket_address()}
socket_address() =
ip_address()
ip_address() = ip4_address() | ip6_address()
ip6_address() =
{0..65535,
…

Alexander Shavelev
- 324
- 1
- 12
0
votes
1 answer
Sending messages from a tcp server in Elixir to a tcp client within an open connection
I developed a TCP server in the Phoenixframwork by using an implementation of the Erlang :gen_tcp module.
I can start the server by calling :gen_tcp.listen(port) which then listens for new connections on this port.
One client is an automated…

Pascal
- 1,984
- 1
- 21
- 25
0
votes
1 answer
rate of acceptance of sockets when using gen_tcp
I found an interesting problem when using gen_tcp behavior. I have a server and a client. The server accepts connections and the client creates many processes that all try to connect to the listening server.
If I try to start the client which…

listen
- 217
- 2
- 7
0
votes
1 answer
Does gen_tcp:recv/3 closes the socket if the timeout is reached?
I currently have a server that handles multiple connections from clients, and client that connects to the server using two connections. My client has two processes that handle respectively sending and receiving to and from the server, but not both.…

Bangosushi
- 94
- 6
0
votes
1 answer
Gen_tcp over gen_server socket listen closed immediatly
I want to use gen_tcp over gen_server, here is the code:
start_link() ->
io:format("start_link~n"),
gen_server:start_link({global, ?MODULE}, ?MODULE, [], []).
init([]) ->
{ok,ListenSocket} = gen_tcp:listen(8091, [{active,true}, binary]),
…

J.R.
- 2,335
- 2
- 19
- 21
0
votes
1 answer
Unable to accept connections on socket, when creating sockets on remote node via RPC in Erlang
I am struggling to identify the reason for gen_tcp:accept always returning an {error, closed} response.
Essentially, I have a supervisor that creates a listening socket:
gen_tcp:listen(8081, [binary, {packet, 0}, {active, false}, {reuseaddr,…

user3813812
- 135
- 6
0
votes
1 answer
Receiving unknown strings lengths?
So I'm converting a Python program I wrote to Erlang, and it's been a long time since I used Erlang. So I guest I'm moved back to beginner level. Anyways from experience every language I use when dealing with sockets have send/recv functions that…

ajm113
- 936
- 1
- 8
- 18
0
votes
1 answer
Erlang: Connect to API with sockets/gen_tcp
I am new to erlang and programming overall and I am looking for a way to connect to the twitter API by using sockets if there even is a way.
So what I am wondering is, is there anyway to pass http requests/URL in sockets to do so?
I would love any…

Erlach
- 1
- 1
0
votes
1 answer
Sending large messages to gen_tcp server in Erlang
I'm trying to implement a client server program.
Server sets up a listening socket with the following code:
gen_tcp:listen(Port, [binary, {active, true}])
The problem is that when the client sends a large message(list of tuples) to the server,…

Elik
- 477
- 3
- 6
- 11