Search
 
SCRIPT & CODE EXAMPLE
 

ERLANG

tcp client erlang

client() ->
    {ok, Sock} = gen_tcp:connect("localhost", 5678, [binary, {packet, 0}]),
    ok = gen_tcp:send(Sock, "Some Data"),
    ok = gen_tcp:close(Sock).
Comment

tcp server erlang

server() ->
    {ok, LSock} = gen_tcp:listen(5678, [binary, {packet, 0}, {active, false}]),
    {ok, Sock} = gen_tcp:accept(LSock),
    {ok, Bin} = do_recv(Sock, []),
    ok = gen_tcp:close(Sock),
    ok = gen_tcp:close(LSock),
    Bin.

do_recv(Sock, Bs) ->
    case gen_tcp:recv(Sock, 0) of
        {ok, B} ->
            do_recv(Sock, [Bs, B]);
        {error, closed} ->
            {ok, list_to_binary(Bs)}
    end.
Comment

PREVIOUS NEXT
Code Example
Assembly :: array month name 
Assembly :: Cannot open self /usr/local/bin/docker-compose 
Assembly :: json vulnerabilities 
Assembly :: 64 bit assembly Hello world 
Assembly :: cmd to know the version of a programm 
Assembly :: how to import servo library in arduino 
Assembly :: creating a sparse-file with dd 
Assembly :: what do you mean by io address and memory address 
Assembly :: vba and 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: chart js remove grid 
Javascript :: datatables remove pagination 
Javascript :: angular current year 
Javascript :: window.reload 
Javascript :: Basic JavaScript: Use Recursion to Create a Countdown 
Javascript :: jquery only number allowed to 10 digit 
Javascript :: jquery selector input by type 
Javascript :: vuex-module-decorators rawError globally 
Javascript :: city regex pattern 
Javascript :: get current url js 
Javascript :: regex remove html tags 
Javascript :: js loop array backwards 
Javascript :: Consider using the "jsdom" test environment. 
Javascript :: js reload iframe 
Javascript :: react-native italics 
Javascript :: moment format datetime postgresql 
Javascript :: Drupal 8 get page node current path 
Javascript :: installing jQuery in react js 
Javascript :: js even or 
Javascript :: breakline in react native 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =