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

Elixir gen_tcp.recv not receiving data on unit test when actual telnet clients work

I have a working telnet server that I am trying to create a unit test for. Server works fine with a telnet client, and is expected to send a prompt as soon as connection is made. Send on the same socket works fine. But, the TCP client from the unit…
davidj
  • 80
  • 4
2
votes
1 answer

process blocked in gen_tcp send/2 because of port command no return

edited at 2015-11-25 02:10 My ejabberd version is 14.12 and erlang R17B, so this code seems not useful because erlang:system_info(otp_release) in R17B retruns "17" ejabberd_listener.erl SockOpts2 = try…
Gang Zhao
  • 126
  • 8
2
votes
1 answer

Erlang gen_tcp is accumulates received data

this my code to receive data -module(t). -compile(export_all). start() -> {ok, LSock} = gen_tcp:listen(5555, [binary, {packet, 0}, {active, false}]), {ok, Sock} = gen_tcp:accept(LSock), {ok, Bin} = do_recv(Sock, []), ok =…
2
votes
1 answer

Is it necessary to close a gen_tcp connection on process termination?

I guess my question is rather straight forward. I am wondering if there is any point in using gen_tcp:close/1 on a socket owned by a process that is about to terminate. The connection is closed automatically and it returns {tcp_closed, Socket} to…
Max
  • 189
  • 7
2
votes
1 answer

Why gen_tcp is not defined in Erlang shell?

After I type gen_ and then type a Tab in erlang shell, I get gen_server, gen_event, but I don't get a gen_tcp. How can I use gen_tcp in Erlang shell?
nicky_zs
  • 3,633
  • 1
  • 18
  • 26
1
vote
3 answers

erlang gen_tcp send issue

Could you please help me? I've a problem related with the gen_tcp send function. I've been trying to send few tuples, about 10-15 items, which were decoded to amf objects, from my erlang server to my flash client. case get_tcp:send(Socket, Msg)…
Sergey
  • 11
  • 1
1
vote
2 answers

What is erlang emsgsize?

Our school project is a BitTorrent client. Today i suddenly got a {tcp_error,#Port<0.2095>,emsgsize} error and my question is what caused this error? I have option {packet,4} on gen_tcp so my guess is that the length off the package does not match…
sakray
  • 21
  • 2
1
vote
0 answers

Erlang gen_tcp:send binary get merged?

Possible Duplicate: gen_tcp smushed messages Sometimes when I send binary data with gen_tcp:send it gets merged in the inbox, example <<0,1>> and <<1,0>> will be received as <<0,1,1,0>>. How can I fix this? Thanks for replies.
sakray
  • 21
  • 2
1
vote
2 answers

Why I keep getting timeout with gen_tcp in Elixir?

I am trying to implement a simple Server (in Go) / Client (in Elixir). However, I keep getting timeouts on Elixir side before my request reaches the server. Server package main import ( "fmt" "net" "net/http" "os" ) func main() { …
Moon
  • 33,439
  • 20
  • 81
  • 132
1
vote
3 answers

Messages using gen_tcp:send doesn't get sent until the socket is closed

I want to write a simple client that sends a message to a server and receives a response. I've got a server that broadcasts the same message to all connected clients and its working when I'm testing it with telnet. When I try doing it using the…
softarn
  • 5,327
  • 3
  • 40
  • 54
1
vote
2 answers

Looking for a simple ssl erlang example

In the book Erlang Programming one of the exercises proposed was to print on screen the request coming from a browser using gen_tcp. I made it for http requests as follows: -module(tcp). -export([server/0, wait_connect/2]). server() -> {ok,…
user601836
  • 3,215
  • 4
  • 38
  • 48
1
vote
1 answer

How to start iex with the environment variable for the PORT of the ListenSocket

I have created a server and a client part for my application and I want to start each node with different port, I want to do it with environment variable how is it possible? here is the server code : defmodule Multichat.Server do require…
Mariem
  • 133
  • 5
1
vote
1 answer

How to disable two nodes to connect on the same port?

I'm making a multichat application and here is the code. In this application I made a server and here is the code : defmodule Multichat.Server do require Logger def accept(port) do {:ok, socket} = :gen_tcp.listen(port, [:binary, packet:…
Mariem
  • 133
  • 5
1
vote
1 answer

Erlang gen_tcp connecting only works on same network

As the question states when I set up my server it can recive messages from the client when its on the same network (different computers but same wifi), yet when the client is on another network it cant reach the server and I have no idea why it…
1
vote
1 answer

How handle only one client simultaneously in erlang gen_tcp?

I have TCP server that listen Ip:Port. listen(Ip, Port) -> Opts = [ binary, {active, false}, {packet, 0}, {reuseaddr, true}, {ip, Ip} ], case gen_tcp:listen(Port, Opts) of {ok, ListenSock} -> …
Alexey Egorov
  • 2,221
  • 2
  • 18
  • 21