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
0
votes
1 answer

Receiving TCP packets as messages instead of using gen_tcp:recv/2

I'm writing a distributed chat application in Erlang for my own learning/benefit. I have a client and a server which maintain a persistent TCP connection. The client initiates the connection using gen_tcp:connect/3. The server is actually…
Cody Poll
  • 7,690
  • 3
  • 27
  • 22
0
votes
2 answers

What's the binary that gen_tcp:recv received?

loop(Socket) -> case gen_tcp:recv(Socket, 0) of {ok, Bin} -> io:format("Bin=~p~n", [Bin]), loop(Socket); {error, Reason} -> io:format("Reason=~p~n", [Reason]) end. {env, [ …
goofansu
  • 2,277
  • 3
  • 30
  • 48
0
votes
1 answer

Send exact number of bytes over a socket

I have read that in Erlang using gen_tcp the data sent over the socket can be aggregated in a single stream. How can i force the socket to send exactly a specific number of bytes?
user601836
  • 3,215
  • 4
  • 38
  • 48
0
votes
1 answer

how long before a process receives a socket closed message

Suppose you have an Erlang process which is handling a socket (gen_tcp/ssl) and the peer closes the connection. How long does it take before the process receives a message like: {tcp_closed, Socket} or {ssl_closed, Socket} Is this amount of time…
user601836
  • 3,215
  • 4
  • 38
  • 48
0
votes
2 answers

receive specific amount of data from gen_tcp socket

I have the following code using a gen_tcp socket, which should receive using {active, true} some binary commands that are always of size 5 (e.g. Command = <<"hello">>) {ok, ListenSocket} = gen_tcp:listen(5555, [{active, true}, {mode, binary}, …
user601836
  • 3,215
  • 4
  • 38
  • 48
1 2 3 4 5
6