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 :: tqdm label 
Assembly :: latex image textwidth 
Assembly :: program in assembly language to find even numbers from 1 to 10 
Assembly :: javafx fxml loader example 
Assembly :: pycryptodome aes 256 cbc 
Assembly :: error: ‘cv’ is not a namespace-name using namespace cv; 
Assembly :: Discord bot name of person being tagged 
Assembly :: vba concatenate strings and integer 
Assembly :: gridbaglayout span 
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
8+3 =