functional programming - Receiving wrong data via TCP Erlang -


i'm trying receive data via tcp socket. when run code below output: localhost^v^a^@, aware need convert data if sending using binary, since sending list thought have been received same? why host string show correctly other data doesn't?

any appreciated, thanks.

cell_process(port, x, y)->     host = "localhost",     data = [host,port,x,y],     {ok, socket} = gen_tcp:connect(host, 22,                                   [list, {packet, 0}]),     ok = gen_tcp:send(socket, data),     ok = gen_tcp:close(socket).   server_process(clientlist)-> {ok, listening_socket} = gen_tcp:listen(22, [list, {packet, 0},                                          {active, false}]), {ok, socket} = gen_tcp:accept(listening_socket),     case gen_tcp:recv(socket,0) of         {ok,message}->             io:fwrite(message);         {error,why}->io:fwrite(why)     end. 

data = [host,port,x,y]is iolist,not list.
gen_tcp:send convert data [<<"localhost">>,<<22:8>>]

here doc of iolist:

iodata() = iolist() | binary() iolist()     maybe_improper_list(char() | binary() | iolist(), binary() | []) maybe_improper_list()     maybe_improper_list(any(), any()) byte()     0..255 char()     0..16#10ffffmaybe_improper_list(t)     maybe_improper_list(t, any()) 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -