connect(host=?, port)

connect([host],port) -> TCPSocket

Connect to the host host on port port

Examples

A simple Echo server

julia> @async begin
         server = listen(2001)
         while true
           sock = accept(server)
           @async while isopen(sock)
             write(sock,readline(sock))
           end
         end
       end
Task

julia> clientside=connect(2001)
TCPSocket(open, 0 bytes waiting)

julia> @async while true
          write(STDOUT,readline(clientside))    # prepare to listen
       end

julia> println(clientside,"Hello World from the Echo Server")

julia> Hello World from the Echo Server

julia> close(clientside)    #disconnect

See Also

accept, bind, :@spawn, connect, fetch, getaddrinfo, gethostname, getipaddr, getsockname, init_worker, IPv4, IPv6, isready, issocket, kill, listen, recv, recvfrom, remotecall, remotecall_fetch, remotecall_wait, RemoteRef, send, setopt,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: